Class SkillComparator

  • All Implemented Interfaces:
    java.util.Comparator<Skill>

    public class SkillComparator
    extends java.lang.Object
    implements java.util.Comparator<Skill>
    A comparator imposing an ordering on Skill objects by comparing the skill level and days.

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

    • Constructor Summary

      Constructors 
      Constructor Description
      SkillComparator()
      Creates a new SkillComparator object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compare​(Skill s1, Skill s2)
      Compares its two arguments for order according to the skill levels and days.
      • 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
    • Field Detail

      • skillCmp

        public static final SkillComparator skillCmp
        A default instance
    • Constructor Detail

      • SkillComparator

        public SkillComparator()
        Creates a new SkillComparator object.
    • Method Detail

      • compare

        public int compare​(Skill s1,
                           Skill s2)
        Compares its two arguments for order according to the skill levels and days.
        Specified by:
        compare in interface java.util.Comparator<Skill>
        Returns:
        a number < 0 if o1's level is larger than the one of o2 or if both levels are equal and o1's days is larger than o2's. A number > 0 is returned if o2's level is larger than o1's or if both levels are equal and o2's days is larger than o1's. 0 is returned if both values are equal.