public class CompareUtil extends Object
Constructor and Description |
---|
CompareUtil() |
Modifier and Type | Method and Description |
---|---|
static <T extends Comparable<T>> |
areNotInAscendingOrder(List<T> values)
Checks if any of the values are not in an ascending order.
|
static <T extends Comparable<T>> |
areNotInAscendingOrder(T... values)
Checks if any of the values are not in an ascending order.
|
static <T> boolean |
elementIsContainedInArray(T element,
T... values)
Checks if the element is contained within the list of values.
|
static <T> boolean |
elementIsContainedInList(T element,
Collection<T> values)
Checks if the element is contained within the list of values.
|
static <T> boolean |
elementIsNotContainedInArray(T element,
T... values)
Checks if the element is contained within the list of values.
|
static <T> boolean |
elementIsNotContainedInList(T element,
Collection<T> values)
Checks if the element is not contained within the list of values.
|
static <T extends Comparable<T>> |
max(T obj1,
T obj2)
Returns any element if obj1.compareTo(obj2) == 0
|
static <T extends Comparable<T>> |
min(T obj1,
T obj2)
Returns any element if obj1.compareTo(obj2) == 0
|
public static <T extends Comparable<T>> boolean areNotInAscendingOrder(T... values)
Comparable.compareTo(Object)
method.
E.g. if we have minPriority = 10
, priority = 13
and maxPriority = 5
and
Integer[] values = {minPriority, priority, maxPriority}
. Then a call to areNotInAscendingOrder(Comparable[] values)
will return true
T
- the type of the comparablevalues
- to validatefalse
if the not null values are in an ascending order or all the values are null, true
otherwisepublic static <T extends Comparable<T>> boolean areNotInAscendingOrder(List<T> values)
Comparable.compareTo(Object)
method.
E.g. if we have minPriority = 10
, priority = 13
and maxPriority = 5
and
List<Integer> values = {minPriority, priority, maxPriority}
. Then a call to areNotInAscendingOrder(List values)
will return true
T
- the type of the comparablevalues
- to validatefalse
if the not null values are in an ascending order or all the values are null, true
otherwisepublic static <T> boolean elementIsNotContainedInList(T element, Collection<T> values)
T
- the type of the elementelement
- to checkvalues
- to check intrue
if the element and values are not null
and the values does not contain the element, false
otherwisepublic static <T> boolean elementIsNotContainedInArray(T element, T... values)
T
- the type of the elementelement
- to checkvalues
- to check intrue
if the element and values are not null
and the values does not contain the element, false
otherwisepublic static <T> boolean elementIsContainedInList(T element, Collection<T> values)
T
- the type of the elementelement
- to checkvalues
- to check intrue
if the element and values are not null
and the values contain the element,
false
otherwisepublic static <T> boolean elementIsContainedInArray(T element, T... values)
T
- the type of the elementelement
- to checkvalues
- to check intrue
if the element and values are not null
and the values contain the element,
false
otherwisepublic static <T extends Comparable<T>> T min(T obj1, T obj2)
public static <T extends Comparable<T>> T max(T obj1, T obj2)
Copyright © 2017. All rights reserved.