|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jopendocument.util.CompareUtils
public class CompareUtils
Nested Class Summary | |
---|---|
static interface |
CompareUtils.Equalizer<T>
|
Field Summary | |
---|---|
static CompareUtils.Equalizer<Object> |
OBJECT_EQ
|
Constructor Summary | |
---|---|
CompareUtils()
|
Method Summary | ||
---|---|---|
static
|
compare(List<T> l1,
List<T> l2,
CompareUtils.Equalizer<? super T> comp,
ITransformer<? super T,String> toString)
Compare two lists using the provided comparator. |
|
static int |
compare(Object o1,
Object o2)
Compare two objects if they're numbers or comparable. |
|
static int |
compareInt(int int1,
int int2)
|
|
static int |
compareIntNumbers(Number n1,
Number n2)
Compare 2 nombres entier avec longValue(). |
|
static int |
compareLong(long int1,
long int2)
|
|
static
|
createComparator(List<? extends Comparator<T>> comparators)
Renvoie un comparateur qui utilise successivement la liste passée tant que les objets sont égaux. |
|
static
|
equals(List<T> l1,
List<T> l2,
CompareUtils.Equalizer<? super T> comp)
|
|
static boolean |
equals(Object o1,
Object o2)
Compare 2 objets pouvant être null . |
|
static
|
equalsWithCompareTo(Comparable<T> o1,
T o2)
Compare 2 objets pouvant être null avec compareTo(). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final CompareUtils.Equalizer<Object> OBJECT_EQ
Constructor Detail |
---|
public CompareUtils()
Method Detail |
---|
public static final int compareIntNumbers(Number n1, Number n2)
n1
- le premier nombre.n2
- le deuxième nombre.
public static final int compareInt(int int1, int int2)
public static final int compareLong(long int1, long int2)
public static final int compare(Object o1, Object o2) throws ClassCastException
o1
- first object.o2
- second object.
ClassCastException
- if o1 is neither a Number
nor a Comparable
, or if
o2's type prevents it from being compared to o1.
NullPointerException
- if o1 or o2 is null
.Comparable.compareTo(Object)
,
NumberUtils.compare(Number, Number)
public static final <T> Comparator<T> createComparator(List<? extends Comparator<T>> comparators)
T
- type of comparatorcomparators
- une liste de Comparator.
public static final boolean equals(Object o1, Object o2)
null
.
o1
- the first object, can be null
.o2
- the second object, can be null
.
true
if both are null
or if o1.equals(o2).Object.equals(Object)
public static final <T> boolean equalsWithCompareTo(Comparable<T> o1, T o2)
null
avec compareTo(). Useful since for some
classes equals() is more specific than compareTo()==0, e.g. BigDecimal.equals(Object)
doesn't compare the numeric value but instance variables (1E2 is not equal to 100 or 100.00).
o1
- the first object, can be null
.o2
- the second object, can be null
.
true
if both are null
or if o1.compareTo(o2) == 0.Comparable.compareTo(Object)
public static final <T> boolean equals(List<T> l1, List<T> l2, CompareUtils.Equalizer<? super T> comp)
public static final <T> String compare(List<T> l1, List<T> l2, CompareUtils.Equalizer<? super T> comp, ITransformer<? super T,String> toString)
T
- type of itemsl1
- the first list.l2
- the second list.comp
- how to compare each item.toString
- how to dispay items, can be null
.
null
if the two lists are equal, otherwise a String explaining the
difference.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |