Class PriorityOrdering<P extends Comparable<? super P>,​T>

java.lang.Object
com.google.common.collect.Ordering<T>
com.github.ferstl.maven.pomenforcers.priority.PriorityOrdering<P,​T>
Type Parameters:
P - Type of the priority collection.
T - Type of the values to be compared.
All Implemented Interfaces:
Comparator<T>

public class PriorityOrdering<P extends Comparable<? super P>,​T> extends com.google.common.collect.Ordering<T>
Comparator that makes comparisons based on a priority collection. Objects that match an item in the priority collection will be considered smaller than objects that don't match any item in the priority collection. If both compared objects match different items in the priority collection, the object that matches the item closer to the beginning of the collection (as returned by the collection's iterator) will be considered smaller. Thus, it is recommended to use Lists or LinkedHashSets to define the priority collection.
  • Constructor Details

    • PriorityOrdering

      public PriorityOrdering(Collection<P> prioritizedItems, Function<T,​P> transformer, com.google.common.base.Equivalence<? super P> priorityMatcher)
    • PriorityOrdering

      public PriorityOrdering(Collection<P> priorityCollection, Function<T,​P> transformer)
  • Method Details

    • compare

      public int compare(T object1, T object2)
      Specified by:
      compare in interface Comparator<P extends Comparable<? super P>>
      Specified by:
      compare in class com.google.common.collect.Ordering<T>