Class UnitFactionDisguisedComparator

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

    public class UnitFactionDisguisedComparator
    extends java.lang.Object
    implements java.util.Comparator<Unit>
    A comparator imposing an ordering on Unit objects by comparing whether they are faction disguised or not.

    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.

    Author:
    Ulrich Küster
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Comparator<? super Unit> subCmp  
    • Constructor Summary

      Constructors 
      Constructor Description
      UnitFactionDisguisedComparator​(java.util.Comparator<? super Unit> subComparator)
      Creates a new UnitFactionDisguisedComparator object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compare​(Unit o1, Unit o2)
      Compares its two arguments for order according to the health-status
      • 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

      • subCmp

        protected java.util.Comparator<? super Unit> subCmp
    • Constructor Detail

      • UnitFactionDisguisedComparator

        public UnitFactionDisguisedComparator​(java.util.Comparator<? super Unit> subComparator)
        Creates a new UnitFactionDisguisedComparator object.
        Parameters:
        subComparator - if two units have the same faction-disguised-status, this sub-comparator is applied if it is not null.
    • Method Detail

      • compare

        public int compare​(Unit o1,
                           Unit o2)
        Compares its two arguments for order according to the health-status
        Specified by:
        compare in interface java.util.Comparator<Unit>