Class AllEqualOrdering

java.lang.Object
com.google.common.collect.Ordering<Object>
com.google.common.collect.AllEqualOrdering
All Implemented Interfaces:
Serializable, Comparator<Object>

final class AllEqualOrdering extends Ordering<Object> implements Serializable
An ordering that treats all references as equals, even nulls.
  • Field Details

  • Constructor Details

    • AllEqualOrdering

      AllEqualOrdering()
  • Method Details

    • compare

      public int compare(@CheckForNull Object left, @CheckForNull Object right)
      Specified by:
      compare in interface Comparator<Object>
      Specified by:
      compare in class Ordering<Object>
    • sortedCopy

      public <E> List<E> sortedCopy(Iterable<E> iterable)
      Description copied from class: Ordering
      Returns a mutable list containing elements sorted by this ordering; use this only when the resulting list may need further modification, or may contain null. The input is not modified. The returned list is serializable and has random access.

      Unlike Sets.newTreeSet(Iterable), this method does not discard elements that are duplicates according to the comparator. The sort performed is stable, meaning that such elements will appear in the returned list in the same order they appeared in elements.

      Performance note: According to our benchmarking on Open JDK 7, Ordering.immutableSortedCopy(java.lang.Iterable<E>) generally performs better (in both time and space) than this method, and this method in turn generally performs better than copying the list and calling Collections.sort(List).

      Overrides:
      sortedCopy in class Ordering<Object>
    • immutableSortedCopy

      public <E> ImmutableList<E> immutableSortedCopy(Iterable<E> iterable)
      Description copied from class: Ordering
      Returns an immutable list containing elements sorted by this ordering. The input is not modified.

      Unlike Sets.newTreeSet(Iterable), this method does not discard elements that are duplicates according to the comparator. The sort performed is stable, meaning that such elements will appear in the returned list in the same order they appeared in elements.

      Performance note: According to our benchmarking on Open JDK 7, this method is the most efficient way to make a sorted copy of a collection.

      Overrides:
      immutableSortedCopy in class Ordering<Object>
    • reverse

      public <S> Ordering<S> reverse()
      Description copied from class: Ordering
      Returns the reverse of this ordering; the Ordering equivalent to Collections.reverseOrder(Comparator).

      Java 8+ users: Use thisComparator.reversed() instead.

      Overrides:
      reverse in class Ordering<Object>
    • readResolve

      private Object readResolve()
    • toString

      public String toString()
      Overrides:
      toString in class Object