|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.staccatocommons.lang.Compare
public class Compare
Class methods that implement comparisons for Comparables, like
between(max, min) and in(collection)
| Constructor Summary | |
|---|---|
Compare()
|
|
| Method Summary | ||
|---|---|---|
static boolean |
between(int element,
int min,
int max)
Tests that given three ints element,
min and max, is true that:
min <= element <= max
|
|
static boolean |
between(long element,
long min,
long max)
Tests that given three longs element,
min and max, is true that:
min <= element <= max
|
|
static
|
between(T min,
T max)
Answers a predicate that evalutes if its argument is between min and max |
|
static
|
between(T element,
T min,
T max)
Tests that given three Comparables element,
min and max, is true that:
min <= element <= max
|
|
static
|
between(T element,
T min,
T max,
Comparator<T> comparator)
Tests that given three Comparables element,
min and max, and a Comparator, using that
comparator is true that:
min <= element <= max
|
|
static
|
greaterThan(T value)
Returns a predicate that evaluates if its argument is greater than the given value. |
|
static
|
greaterThanOrEqualTo(T value)
Returns a predicate that evaluates if its argument is greater than or equal to the given value. |
|
static
|
in_(T... values)
Returns a predicate that tests if its argument is equal to any of the given values |
|
static boolean |
in(int element,
int[] values)
Tests if a given array contains an element |
|
static boolean |
in(long element,
long[] values)
Tests if a given array contains an element |
|
static
|
in(T element,
T... values)
Tests if a given array contains an element |
|
static
|
lessThan(T value)
Returns a predicate that evaluates if its argument is less than the given value. |
|
static
|
lessThanOrEqualTo(T value)
Returns a predicate that evaluates if its argument is lower than or equal to the given value. |
|
static
|
max(Comparator<? super A> comparator)
Answers a new AbstractFunction2 that returns the max of its
arguments using the given comparator. |
|
static
|
max(T c1,
T c2)
|
|
static
|
max(T c1,
T c2,
Comparator<? super T> comparator)
Answers the min element between c1 and c2, using
the given Comparator |
|
static
|
min(Comparator<? super A> comparator)
Answers a new AbstractFunction2 that returns the min of its
arguments using the given comparator. |
|
static
|
min(T c1,
T c2)
|
|
static
|
min(T c1,
T c2,
Comparator<? super T> comparator)
Answers the max element between c1 and c2, using
the given Comparator |
|
static
|
natural()
Answers a natural comparator, that is, a comparator that compares elements using its natural order, as defined by Comparable. |
|
static
|
on(net.sf.staccatocommons.defs.Applicable<? super A,B> function)
Answers a new Comparator that performs the comparison between the
results of applying the given function to its arguments. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Compare()
| Method Detail |
|---|
public static <T extends Comparable<T>> boolean between(@NonNull
T element,
@NonNull
T min,
@NonNull
T max)
Comparables element,
min and max, is true that:
min <= element <= max
T - the type of comparable elementelement - non nullmin - non nullmax - non null
public static <T> boolean between(@NonNull
T element,
@NonNull
T min,
@NonNull
T max,
@NonNull
Comparator<T> comparator)
Comparables element,
min and max, and a Comparator, using that
comparator is true that:
min <= element <= max
T - the type of comparable elementelement - non nullmin - non nullmax - non nullcomparator - non null
Comparator as ordering criteria
public static boolean between(long element,
long min,
long max)
longs element,
min and max, is true that:
min <= element <= max
element - non nullmin - non nullmax - non null
public static boolean between(int element,
int min,
int max)
ints element,
min and max, is true that:
min <= element <= max
element - non nullmin - non nullmax - non null
public static <T extends Comparable<T>> net.sf.staccatocommons.defs.predicate.Predicate<T> between(@NonNull
T min,
@NonNull
T max)
min and max
T - min - max -
Predicate
public static boolean in(int element,
@NonNull
int[] values)
element - values -
public static boolean in(long element,
@NonNull
long[] values)
element - values -
public static <T> boolean in(@NonNull
T element,
@NonNull
T... values)
T - element - values -
public static <T> net.sf.staccatocommons.defs.predicate.Predicate<T> in_(@NonNull
T... values)
T - values -
Predicate
@NonNull
public static <T extends Comparable<T>> T min(@NonNull
T c1,
@NonNull
T c2)
T - c1 - c2 -
@NonNull
public static <T extends Comparable<T>> T max(@NonNull
T c1,
@NonNull
T c2)
T - c1 - c2 -
@NonNull
public static <A> net.sf.staccatocommons.defs.function.Function2<A,A,A> min(@NonNull
Comparator<? super A> comparator)
AbstractFunction2 that returns the min of its
arguments using the given comparator.
A - comparator -
AbstractFunction2
@NonNull
public static <A> net.sf.staccatocommons.defs.function.Function2<A,A,A> max(@NonNull
Comparator<? super A> comparator)
AbstractFunction2 that returns the max of its
arguments using the given comparator.
A - comparator -
AbstractFunction2
@NonNull
public static <T> T max(@NonNull
T c1,
@NonNull
T c2,
@NonNull
Comparator<? super T> comparator)
c1 and c2, using
the given Comparator
T - c1 - c2 - comparator -
comparator.compare(c1, c2) >= 0 ? c1 : c2
@NonNull
public static <T> T min(@NonNull
T c1,
@NonNull
T c2,
Comparator<? super T> comparator)
c1 and c2, using
the given Comparator
T - c1 - c2 - comparator -
comparator.compare(c1, c2) <= 0 ? c1 : c2
@NonNull
public static <A,B extends Comparable<B>> Comparator<A> on(@NonNull
net.sf.staccatocommons.defs.Applicable<? super A,B> function)
Comparator that performs the comparison between the
results of applying the given function to its arguments.
A - B - function -
Comparator
public static <T extends Comparable<T>> net.sf.staccatocommons.defs.predicate.Predicate<T> lessThan(@NonNull
T value)
argument.compareTo(value) < 0
T - value -
public static <T extends Comparable<T>> net.sf.staccatocommons.defs.predicate.Predicate<T> lessThanOrEqualTo(@NonNull
T value)
argument.compareTo(value) <= 0
T - value -
public static <T extends Comparable<T>> net.sf.staccatocommons.defs.predicate.Predicate<T> greaterThan(@NonNull
T value)
argument.compareTo(value) > 0
T - value -
public static <T extends Comparable<T>> net.sf.staccatocommons.defs.predicate.Predicate<T> greaterThanOrEqualTo(@NonNull
T value)
argument.compareTo(value) >= 0
T - value -
@Constant public static <A extends Comparable<A>> Comparator<A> natural()
Comparable.
A -
Comparator
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||