Class MessageBodyFactory.DeclarationDistanceComparator<T>

java.lang.Object
org.glassfish.jersey.message.internal.MessageBodyFactory.DeclarationDistanceComparator<T>
Type Parameters:
T - common super-type used for computing the declaration distance and comparing instances.
All Implemented Interfaces:
Comparator<T>
Enclosing class:
MessageBodyFactory

private static class MessageBodyFactory.DeclarationDistanceComparator<T> extends Object implements Comparator<T>
Compares 2 instances implementing/inheriting the same super-type and returns which of the two instances has the super-type declaration closer in it's inheritance hierarchy tree.

The comparator is optimized to cache results of the previous distance declaration computations.

  • Field Details

  • Constructor Details

    • DeclarationDistanceComparator

      DeclarationDistanceComparator(Class<T> declared)
  • Method Details

    • compare

      public int compare(T o1, T o2)
      Specified by:
      compare in interface Comparator<T>
    • getDistance

      private int getDistance(T t)