Class SpecifiedSkillTypeSkillComparator

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

    public class SpecifiedSkillTypeSkillComparator
    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 skills of the given SkillType 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
      SpecifiedSkillTypeSkillComparator​(SkillType skillType, java.util.Comparator<? super Skill> skillComparator, java.util.Comparator<? super java.util.Map<? extends ID,​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

      • SpecifiedSkillTypeSkillComparator

        public SpecifiedSkillTypeSkillComparator​(SkillType skillType,
                                                 java.util.Comparator<? super Skill> skillComparator,
                                                 java.util.Comparator<? super java.util.Map<? extends ID,​Skill>> subComparator)
        Creates a new BestSkillComparator object.
        Parameters:
        skillType - used to determine the best skill in each of the two collections of skills to be compared.
        skillComparator - used to compare the two best skills.
        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 given skilltype - smallest skills in o1 and o2. Undefined values are evaluated as > 0.