org.infinispan.commons.equivalence
Class ByteArrayEquivalence

java.lang.Object
  extended by org.infinispan.commons.equivalence.ByteArrayEquivalence
All Implemented Interfaces:
Serializable, Equivalence<byte[]>

public class ByteArrayEquivalence
extends Object
implements Equivalence<byte[]>

A compare function for unsigned byte arrays.

Since:
5.3
Author:
Galder ZamarreƱo
See Also:
Serialized Form

Field Summary
static Equivalence<byte[]> INSTANCE
           
 
Constructor Summary
ByteArrayEquivalence()
           
 
Method Summary
 int compare(byte[] obj, byte[] otherObj)
          Compares the two given objects for order.
 boolean equals(byte[] obj, Object otherObj)
          Indicates whether the objects passed are "equal to" each other.
 int hashCode(Object obj)
          Returns a hash code value for the object passed.
 boolean isComparable(Object obj)
          Returns whether the given object is comparable.
 String toString(Object obj)
          Returns a string representation of the given object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final Equivalence<byte[]> INSTANCE
Constructor Detail

ByteArrayEquivalence

public ByteArrayEquivalence()
Method Detail

hashCode

public int hashCode(Object obj)
Description copied from interface: Equivalence
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 Object.hashCode(), call java.util.Arrays.hashCode().

Specified by:
hashCode in interface Equivalence<byte[]>
Parameters:
obj - instance to calculate hash code for
Returns:
a hash code value for the object passed as parameter

equals

public boolean equals(byte[] obj,
                      Object otherObj)
Description copied from interface: Equivalence
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 Object.equals(Object)}, call java.util.Arrays.equals()).

Specified by:
equals in interface Equivalence<byte[]>
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

toString

public String toString(Object obj)
Description copied from interface: Equivalence
Returns a string representation of the given object.

Specified by:
toString in interface Equivalence<byte[]>
Parameters:
obj - whose string representation is to be returned
Returns:
a string representation of the passed object

isComparable

public boolean isComparable(Object obj)
Description copied from interface: Equivalence
Returns whether the given object is comparable. In other words, if given an instance of the object, a sensible comparison can be computed using Equivalence.compare(Object, Object) method.

Specified by:
isComparable in interface Equivalence<byte[]>
Parameters:
obj - instance to check if it's comparable
Returns:
true if the object is comparable; false otherwise

compare

public int compare(byte[] obj,
                   byte[] otherObj)
Description copied from interface: Equivalence
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.

Specified by:
compare in interface Equivalence<byte[]>
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

-->

Copyright © 2013 JBoss, a division of Red Hat. All Rights Reserved.