Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.infinispan.commons.equivalence;
 
An interface that allows custom implementations for objects that are comparable based on equality, hash code calculations, or according to java.lang.Comparable rules, but where the behaviour provided by the JDK, or external libraries, cannot be modified, for example: arrays. The interface is marked to be java.io.Serializable because multiple collection extensions within the Infinispan code base contain references to them, and since these are potentially java.io.Serializable, they might be persisted somehow.

Author(s):
Galder ZamarreƱo
Since:
5.3
public interface Equivalence<T> extends Serializable {

   
Returns a hash code value for the object passed. As an example, implementors can provide an alternative implementation for the hash code calculation for arrays. So, instead of relying on java.lang.Object.hashCode(), call java.util.Arrays.hashCode().

Parameters:
obj instance to calculate hash code for
Returns:
a hash code value for the object passed as parameter
   int hashCode(Object obj);

   
Indicates whether the objects passed are "equal to" each other. As an example, implementors can provide an alternative implementation for the equals for arrays. So, instead of relying on java.lang.Object.equals(java.lang.Object)}, call java.util.Arrays.equals()).

Parameters:
obj to be compared with second parameter
otherObj to be compared with first parameter
Returns:
true if both objects are the same; false otherwise
   boolean equals(T objObject otherObj);

   
Returns a string representation of the given object.

Parameters:
obj whose string representation is to be returned
Returns:
a string representation of the passed object
   String toString(Object obj);

   
Returns whether the given object is comparable. In other words, if given an instance of the object, a sensible comparison can be computed using compare(java.lang.Object,java.lang.Object) method.

Parameters:
obj instance to check if it's comparable
Returns:
true if the object is comparable; false otherwise
   boolean isComparable(Object obj); // For future support for objects that are not comparable, i.e. arrays

   
Compares the two given objects for order. Returns a negative integer, zero, or a positive integer as the first object is less than, equal to, or greater than the second object.

Parameters:
obj first object to be compared
otherObj second object to be compared
Returns:
a negative integer, zero, or a positive integer as the first object is less than, equal to, or greater than the second object
   int compare(T obj, T otherObj); // For future support for objects that are not comparable, i.e. arrays
New to GrepCode? Check out our FAQ X