Class BestSkillComparator

  • All Implemented Interfaces:
    java.util.Comparator<java.util.Map<? extends ID,​Skill>>

    public class BestSkillComparator
    extends java.lang.Object
    implements java.util.Comparator<java.util.Map<? extends ID,​Skill>>
    A comparator imposing an ordering on collections of Skill objects by comparing the best skills available in each set.

    Note: this comparator imposes orderings that are inconsistent with equals.

    In order to overcome the inconsistency with equals this comparator allows the introduction of a sub-comparator which is applied in cases of equality.

    • Constructor Summary

      Constructors 
      Constructor Description
      BestSkillComparator​(java.util.Comparator<? super Skill> bestComparator, java.util.Comparator<? super Skill> skillTypeComparator, java.util.Comparator<? super Skill> subComparator)
      Creates a new BestSkillComparator object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compare​(java.util.Map<? extends ID,​Skill> o1, java.util.Map<? extends ID,​Skill> o2)
      Compares its two arguments for order according to their skills.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Comparator

        equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
    • Constructor Detail

      • BestSkillComparator

        public BestSkillComparator​(java.util.Comparator<? super Skill> bestComparator,
                                   java.util.Comparator<? super Skill> skillTypeComparator,
                                   java.util.Comparator<? super Skill> subComparator)
        Creates a new BestSkillComparator object.
        Parameters:
        bestComparator - used to determine the best skill in each of the two collections of skills to be compared.
        skillTypeComparator - used to compare the two best skillTypes.
        subComparator - applied when the best skills are equal or cannot be determined.
    • Method Detail

      • compare

        public int compare​(java.util.Map<? extends ID,​Skill> o1,
                           java.util.Map<? extends ID,​Skill> o2)
        Compares its two arguments for order according to their skills.
        Specified by:
        compare in interface java.util.Comparator<java.util.Map<? extends ID,​Skill>>
        Returns:
        the result of the skill comparator applied to the - according to the best comparator - smallest skills in o1 and o2. Undefined values are evaluated as > 0.