public final class EqualsHashCodeAndToStringCheck extends Object
EqualsHashCodeAndToStringCheck is a combination of all checks.| Constructor and Description |
|---|
EqualsHashCodeAndToStringCheck() |
| Modifier and Type | Method and Description |
|---|---|
static <T> Optional<ContractViolation> |
equalsAndHashcode(T first,
T second,
T third,
T fourth)
Checks all the contract conditions for the methods
Object.equals(Object) and
Object.hashCode(). |
static <T> Optional<ContractViolation> |
equalsAndHashcodeEquality(T object,
T otherObject)
Checks the contract conditions for reflexivity, non null, symmetric and consistency of the
given objects, that means according to
Object.equals(Object) that this method should
evaluate the following contract condition:
It is reflexive: for any non-null reference value x, x.equals(x)
should return true. |
static <T> Optional<ContractViolation> |
equalsAndHashcodeUnequality(T object,
T otherObject)
Checks the contract conditions for reflexivity, non null, symmetric and consistency of the
given objects, that means according to
Object.equals(Object) that this method should
evaluate the following contract condition:
It is reflexive: for any non-null reference value x, x.equals(x)
should return true. |
static <T> Optional<ContractViolation> |
equalsHashcodeAndToString(Class<T> cls)
Checks all the contract conditions for the methods
Object.equals(Object),
Object.hashCode() and Object.toString() from the given Class. |
static <T> Optional<ContractViolation> |
equalsHashcodeAndToString(Class<T> cls,
Function<Class<T>,T> function)
Checks all the contract conditions for the methods
Object.equals(Object),
Object.hashCode() and Object.toString() from the given Class. |
static <T> Optional<ContractViolation> |
equalsHashcodeAndToString(T object)
Checks the contract conditions for reflexivity and non null, that means according to
Object.equals(Object) that this method should evaluate the following contract
condition:
It is reflexive: for any non-null reference value x, x.equals(x)
should return true. |
static <T> Optional<ContractViolation> |
equalsHashcodeAndToString(T first,
T second,
T third,
T fourth)
Checks the all the contract conditions for the methods
Object.equals(Object),
Object.hashCode() and Object.toString(). |
static <T> Optional<ContractViolation> |
hashcodeCheck(T first,
T second,
T fourth)
Checks all the contract conditions for the method
Object.hashCode() |
public static <T> Optional<ContractViolation> equalsAndHashcode(T first, T second, T third, T fourth)
Object.equals(Object) and
Object.hashCode().T - the generic typefirst - the first objectsecond - the second object that have to be uneqal to the first objectthird - the third object have to be equal to first object and fourth objectfourth - the fourth object have to be equal to first object and third objectOptional if no violation occurred or an Optional with the
specific violation typepublic static <T> Optional<ContractViolation> hashcodeCheck(T first, T second, T fourth)
Object.hashCode()T - the generic typefirst - the first objectsecond - the second object that have to be uneqal to the first objectfourth - the fourth object have to be equal to first object and third objectOptional if no violation occurred or an Optional with the
specific violation typepublic static <T> Optional<ContractViolation> equalsAndHashcodeEquality(T object, T otherObject)
Object.equals(Object) that this method should
evaluate the following contract condition:
x, x.equals(x)
should return true.
x, x.equals(null) should return
false.
x and y,
x.equals(y) should return true if and only if y.equals(x) returns
true.
x and y,
multiple invocations of x.equals(y) consistently return true or consistently
return false, provided no information used in equals comparisons on the
objects is modified.
Object.equals(Object)
Evaluate equality of hash code from the given objects that should be equal(if not an
IllegalArgumentException will be thrown), that means according to
Object.hashCode() that this method should evaluate the following contract condition:
equals(Object) method, then calling the
hashCode method on each of the two objects must produce the same integer result.
public static <T> Optional<ContractViolation> equalsAndHashcodeUnequality(T object, T otherObject)
Object.equals(Object) that this method should
evaluate the following contract condition:
x, x.equals(x)
should return true.
x, x.equals(null) should return
false.
x and y,
x.equals(y) should return true if and only if y.equals(x) returns
true.
x and y,
multiple invocations of x.equals(y) consistently return true or consistently
return false, provided no information used in equals comparisons on the
objects is modified.
Object.equals(Object)
Evaluate unequality of hash code from the given objects that should be unequal(if not an
IllegalArgumentException will be thrown), that means according to
Object.hashCode() that this method should evaluate the following contract condition:
Object.equals(java.lang.Object) method, then calling the hashCode
method on each of the two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results for unequal objects may
improve the performance of hash tables.
public static <T> Optional<ContractViolation> equalsHashcodeAndToString(Class<T> cls) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, IOException
Object.equals(Object),
Object.hashCode() and Object.toString() from the given Class.T - the generic typecls - the classOptional if no violation occurred or an Optional with the
specific violation typeIllegalAccessException - if the caller does not have access to the property accessor methodInstantiationException - if a new instance of the bean's class cannot be instantiatedInvocationTargetException - if the property accessor method throws an exceptionNoSuchMethodException - if an accessor method for this property cannot be foundIOException - Signals that an I/O exception has occurredpublic static <T> Optional<ContractViolation> equalsHashcodeAndToString(Class<T> cls, Function<Class<T>,T> function) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, IOException
Object.equals(Object),
Object.hashCode() and Object.toString() from the given Class.T - the generic typecls - the classfunction - the function that can create random objectsOptional if no violation occurred or an Optional with the
specific violation typeIllegalAccessException - if the caller does not have access to the property accessor methodInstantiationException - if a new instance of the bean's class cannot be instantiatedInvocationTargetException - if the property accessor method throws an exceptionNoSuchMethodException - if an accessor method for this property cannot be foundIOException - Signals that an I/O exception has occurredpublic static <T> Optional<ContractViolation> equalsHashcodeAndToString(T object)
Object.equals(Object) that this method should evaluate the following contract
condition:
x, x.equals(x)
should return true.
x, x.equals(null) should return
false.
Object.equals(Object)
Evaluate consistency of the given object, that means according to Object.hashCode()
that this method should evaluate the following contract condition:
hashCode method must consistently return the same integer, provided
no information used in equals comparisons on the object is modified. This integer
need not remain consistent from one execution of an application to another execution of the
same application.
Object.hashCode()public static <T> Optional<ContractViolation> equalsHashcodeAndToString(T first, T second, T third, T fourth)
Object.equals(Object),
Object.hashCode() and Object.toString().T - the generic typefirst - the first objectsecond - the second object that have to be uneqal to the first objectthird - the third object have to be equal to first object and fourth objectfourth - the fourth object have to be equal to first object and third objectObject.equals(Object),
Object.hashCode() and Object.toString() is given otherwise falseCopyright © 2015–2018 Alpha Ro Group UG (haftungsbeschrÀngt). All rights reserved.