public class CompareTo<T extends Comparable<T>> extends Object
Comparable.compareTo(Object).
Examples:
import static se.jiderhamn.CompareTo.is;
...
boolean oneIsZero = is(1).equalTo(0);
boolean aIsNotZero = is(a).notEqualTo(0);
boolean bIsZero = is(b).zero();
boolean value1LessThanValue2 = is(value1).lessThan(value2);
if(is(a).lessThanOrEqualTo(b)) {
...
}
boolean date1AfterDate2 = is(date1).greaterThan(date2);
if(is(a).greaterThanOrEqualTo(b)) {
...
}
// Abbreviated syntax
boolean oneIsZero = is(1).eq(0);
boolean aIsNotZero = is(a).ne(0);
boolean value1LessThanValue2 = is(value1).lt(value2);
if(is(a).le(b)) {
...
}
boolean date1AfterDate2 = is(date1).gt(date2);
if(is(a).ge(b)) {
...
}
| Modifier and Type | Method and Description |
|---|---|
boolean |
after(T that)
Is the owner after the argument?
|
boolean |
before(T that)
Is the owner before the argument?
|
boolean |
eq(T that)
Is the owner equal to the argument?
|
boolean |
equalTo(T that)
Is the owner equal to the argument?
|
boolean |
ge(T that)
Is the owner greater than or equal to the argument?
|
boolean |
greaterThan(T that)
Is the owner greater than the argument?
|
boolean |
greaterThanOrEqualTo(T that)
Is the owner greater than or equal to the argument?
|
boolean |
gt(T that)
Is the owner greater than the argument?
|
static <C extends Comparable<C>> |
is(C comparable)
Create new instance that allows for chained comparison
|
boolean |
le(T that)
Is the owner less than or equal to the argument?
|
boolean |
lessThan(T that)
Is the owner less than the argument?
|
boolean |
lessThanOrEqualTo(T that)
Is the owner less than or equal to the argument?
|
boolean |
lt(T that)
Is the owner less than the argument?
|
boolean |
ne(T that)
Is the owner not equal to the argument?
|
boolean |
notEqualTo(T that)
Is the owner not equal to the argument?
|
boolean |
zero()
Is the owner equal to zero (regardless of scale)?
|
public static <C extends Comparable<C>> CompareTo<C> is(C comparable)
public boolean equalTo(T that)
public boolean eq(T that)
public boolean notEqualTo(T that)
public boolean ne(T that)
public boolean lessThan(T that)
public boolean lessThanOrEqualTo(T that)
public boolean lt(T that)
public boolean le(T that)
public boolean before(T that)
lessThan(Comparable)public boolean greaterThan(T that)
public boolean greaterThanOrEqualTo(T that)
public boolean gt(T that)
public boolean ge(T that)
public boolean after(T that)
greaterThan(Comparable)public boolean zero()
is(null).zero() == false.IllegalArgumentException - for any non-numeric owner type.Copyright © 2013. All Rights Reserved.