@Immutable public final class EqualsHelper extends Object
equals method generation| Modifier and Type | Method and Description |
|---|---|
static boolean |
equals(boolean aObj1,
boolean aObj2)
Check if two values are equal.
|
static boolean |
equals(byte aObj1,
byte aObj2)
Check if two values are equal.
|
static boolean |
equals(char aObj1,
char aObj2)
Check if two values are equal.
|
static boolean |
equals(double aObj1,
double aObj2)
Check if two double values are equal.
|
static boolean |
equals(float aObj1,
float aObj2)
Check if two float values are equal.
|
static boolean |
equals(int aObj1,
int aObj2)
Check if two values are equal.
|
static boolean |
equals(long aObj1,
long aObj2)
Check if two values are equal.
|
static boolean |
equals(Object aObj1,
Object aObj2)
Check if two values are equal.
|
static boolean |
equals(short aObj1,
short aObj2)
Check if two values are equal.
|
static boolean |
equalsAsList(Object aObj1,
Object aObj2)
This is a sanity method that first calls
CollectionHelper.getAsList(Object) on both objects an than calls
equalsCollectionOnly(Collection, Collection) on the collections. |
static boolean |
equalsCollection(Object aObj1,
Object aObj2)
Check if the content of the passed containers is equal.
|
static <T> boolean |
equalsCollectionOnly(Collection<T> aCont1,
Collection<?> aCont2) |
static <T> boolean |
equalsCustom(T aObj1,
T aObj2,
BiPredicate<T,T> aPredicate)
Perform an equals check with a custom predicate that is only invoked, if
both objects are non-
null. |
static <T> boolean |
equalsEumeration(Enumeration<T> aEnum1,
Enumeration<?> aEnum2) |
static boolean |
equalsIgnoreCase(String sObj1,
String sObj2)
Check if the passed strings are equals case insensitive handling
null appropriately. |
static <T> boolean |
equalsIterator(Iterator<T> aIter1,
Iterator<?> aIter2) |
static <K,V> boolean |
equalsMap(Map<K,V> aCont1,
Map<?,?> aCont2) |
static <T> boolean |
equalsSet(Set<T> aCont1,
Set<?> aCont2) |
static <T> boolean |
identityEqual(T aObj1,
T aObj2)
The only place where objects are compared by identity.
|
public static <T> boolean identityEqual(@Nullable T aObj1, @Nullable T aObj2)
T - Type to check.aObj1 - First object. May be null.aObj2 - Second object. May be null.true if both objects are null or
reference the same object.public static boolean equals(boolean aObj1,
boolean aObj2)
aObj1 - First valueaObj2 - Second valuetrue if they are equal, false otherwise.public static boolean equals(byte aObj1,
byte aObj2)
aObj1 - First valueaObj2 - Second valuetrue if they are equal, false otherwise.public static boolean equals(char aObj1,
char aObj2)
aObj1 - First valueaObj2 - Second valuetrue if they are equal, false otherwise.public static boolean equals(double aObj1,
double aObj2)
aObj1 - First doubleaObj2 - Second doubletrue if they are equal, false otherwise.public static boolean equals(float aObj1,
float aObj2)
aObj1 - First floataObj2 - Second floattrue if they are equal, false otherwise.public static boolean equals(int aObj1,
int aObj2)
aObj1 - First valueaObj2 - Second valuetrue if they are equal, false otherwise.public static boolean equals(long aObj1,
long aObj2)
aObj1 - First valueaObj2 - Second valuetrue if they are equal, false otherwise.public static boolean equals(short aObj1,
short aObj2)
aObj1 - First valueaObj2 - Second valuetrue if they are equal, false otherwise.public static boolean equals(@Nullable Object aObj1, @Nullable Object aObj2)
aObj1 - First valueaObj2 - Second valuetrue if they are equal, false otherwise.EqualsImplementationRegistry.areEqual(Object, Object)public static boolean equalsIgnoreCase(@Nullable String sObj1, @Nullable String sObj2)
null appropriately.sObj1 - First object to comparesObj2 - Second object to comparetrue if they are equal case insensitive,
false otherwise.public static <T> boolean equalsCollectionOnly(@Nonnull Collection<T> aCont1, @Nonnull Collection<?> aCont2)
public static <T> boolean equalsIterator(@Nonnull Iterator<T> aIter1, Iterator<?> aIter2)
public static <T> boolean equalsEumeration(@Nonnull Enumeration<T> aEnum1, Enumeration<?> aEnum2)
public static boolean equalsCollection(@Nullable Object aObj1, @Nullable Object aObj2)
EqualsImplementationRegistry.areEqual(Object, Object) method is
invoked to test for equality!aObj1 - The first container. May be null.aObj2 - The second container. May be null.true if both objects are the same, or if they have the
same meta type and have the same content.IllegalArgumentException - if one of the arguments is not a container!public static boolean equalsAsList(@Nullable Object aObj1, @Nullable Object aObj2)
CollectionHelper.getAsList(Object) on both objects an than calls
equalsCollectionOnly(Collection, Collection) on the collections.
This means that calling this method with the String array ["a", "b"] and
the List<String> ("a", "b") will result in a return value of true.aObj1 - The first object to be compared. May be null.aObj2 - The second object to be compared. May be null.true if the contents are equal, false
otherwisepublic static <T> boolean equalsCustom(@Nullable T aObj1, @Nullable T aObj2, @Nonnull BiPredicate<T,T> aPredicate)
null.T - parameter typeaObj1 - The first object to be compared. May be null.aObj2 - The second object to be compared. May be null.aPredicate - The predicate to be invoked, if both objects are
non-null. May not be null.true if the contents are equal, false
otherwiseCopyright © 2014–2022 Philip Helger. All rights reserved.