Code Monkey home page Code Monkey logo

comprule's Introduction

comprule

compare number by rule expression like 'eq0', 'gt2', 'lt3', 'neq9', 'ngt8', 'nlt5'. If you have other requirement, feel free to contact me.

这个项目定义了一个数字比较的语义,方便大家。如有其他需求,可以联系我。

                                                                                                                                               
表达式语义
eqequal(等于)
eqequal(等于)
neqnot equal(不等于)
ltless than(小于)
nltnot less than(不小于即大于等于)
gtgreater than(大于)
ngtnot greater than(不大于即小于等于)

how to use

You can run it like following:

        System.out.println("1 = 1? " + CompareUtils.compare(1, "eq1"));
        System.out.println("-1 = -1? " + (CompareUtils.compare(-1, "eq-1")));
        System.out.println("0 = 0? " + CompareUtils.compare(0, "eq0"));
        System.out.println("1 = 0? " + CompareUtils.compare(1, "eq0"));
        System.out.println("1 > -1? " + CompareUtils.compare(1, "gt-1"));
        System.out.println("1 > 0? " + CompareUtils.compare(1, "gt0"));
        System.out.println("1 > 1? " + CompareUtils.compare(1, "gt1"));
        System.out.println("1 > 2? " + CompareUtils.compare(1, "gt2"));
        System.out.println("1 < 2? " + CompareUtils.compare(1, "lt2"));
        System.out.println("2 < 2? " + CompareUtils.compare(2, "lt2"));
        System.out.println("2 >= 2? " + CompareUtils.compare(2, "nlt2"));
        System.out.println("3 >= 2? " + CompareUtils.compare(3, "nlt2"));
        System.out.println("1 >= 2? " + CompareUtils.compare(1, "nlt2"));
        System.out.println("2 <= 2? " + CompareUtils.compare(2, "ngt2"));
        System.out.println("3 <= 2? " + CompareUtils.compare(3, "ngt2"));
        System.out.println("1 <= 2? " + CompareUtils.compare(1, "ngt2"));
        System.out.println("2 != 2? " + CompareUtils.compare(2, "neq2"));
        System.out.println("1 != 2? " + CompareUtils.compare(1, "neq2"));
        System.out.println("257 > 256? " + CompareUtils.compare(257, "gt256"));
        System.out.println("256 = 256? " + CompareUtils.compare(256, "eq256"));
        System.out.println("255 = 256? " + CompareUtils.compare(255, "gt256"));

how to build

git clone this project and run 'mvn package', then you can get the jar file in target/ folder.

the next step

I am thinking how to add this project to maven repository.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.