IdentifiableComparator.java

  1. package net.sf.uadetector.internal.data;

  2. import java.util.Comparator;

  3. import javax.annotation.concurrent.ThreadSafe;

  4. import net.sf.uadetector.internal.data.domain.Identifiable;
  5. import net.sf.uadetector.internal.util.CompareNullSafe;

  6. @ThreadSafe
  7. public final class IdentifiableComparator extends CompareNullSafe<Identifiable> implements Comparator<Identifiable> {

  8.     public static final IdentifiableComparator INSTANCE = new IdentifiableComparator();

  9.     private static final long serialVersionUID = -4279820324904203666L;

  10.     /**
  11.      * <strong>Attention:</strong> This class is a stateless singleton and not intended to create more than one object
  12.      * from it.
  13.      */
  14.     private IdentifiableComparator() {
  15.         // This class is not intended to create own objects from it.
  16.     }

  17.     @Override
  18.     public int compareType(final Identifiable o1, final Identifiable o2) {
  19.         return compareInt(o1.getId(), o2.getId());
  20.     }

  21. }