Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.infinispan.commons.equivalence;

A compare function for objects.

Author(s):
Galder ZamarreƱo
Since:
5.3
 
 public final class AnyEquivalence<T> implements Equivalence<T> {
   private static AnyEquivalence<ObjectOBJECT = new AnyEquivalence<Object>();
   public static AnyEquivalence<StringSTRING = new AnyEquivalence<String>();
   public static AnyEquivalence<ByteBYTE = new AnyEquivalence<Byte>();
   public static AnyEquivalence<ShortSHORT = new AnyEquivalence<Short>();
   public static AnyEquivalence<IntegerINT = new AnyEquivalence<Integer>();
   public static AnyEquivalence<LongLONG = new AnyEquivalence<Long>();
   public static AnyEquivalence<DoubleDOUBLE  = new AnyEquivalence<Double>();
   public static AnyEquivalence<FloatFLOAT = new AnyEquivalence<Float>();
   public static AnyEquivalence<BooleanBOOLEAN = new AnyEquivalence<Boolean>();
   // To avoid instantiation
   private AnyEquivalence() {
   }
   @Override
   public int hashCode(Object obj) {
      return obj.hashCode();
   }
   @Override
   public boolean equals(T objObject otherObj) {
      return obj != null && obj.equals(otherObj);
   }
   @Override
   public String toString(Object obj) {
      return obj.toString();
   }
   @Override
   public boolean isComparable(Object obj) {
      return obj instanceof Comparable;
   }
   @Override
   @SuppressWarnings("unchecked")
   public int compare(T obj, T otherObj) {
      return ((Comparable<T>) obj).compareTo(otherObj);
   }
   @SuppressWarnings("unchecked")
   public static <T> AnyEquivalence<T> getInstance() {
      return (AnyEquivalence<T>) ;
   }
New to GrepCode? Check out our FAQ X