Class AirportComparator
- All Implemented Interfaces:
Serializable, Comparator<Airport>
A comparator for Airport beans.
- Since:
- 1.0
- Version:
- 9.0
- Author:
- Luke
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intFields inherited from class AbstractComparator
_comparisonType, _typeNamesModifier and TypeFieldDescriptionprotected intThe criteria by which to compare objects.protected String[]Text descriptions of the different comparison types. -
Constructor Summary
ConstructorsConstructorDescriptionAirportComparator(int comparisonType) Creates a new AirportComparator with a given comparison typeAirportComparator(String comparisonType) Creates a new AirportComparator with a given comparison type -
Method Summary
Modifier and TypeMethodDescriptionprotected intcompareImpl(Airport a1, Airport a2) Compares two airports by the designated criteriaMethods inherited from class AbstractComparator
compare, getComparisonType, getTypeNames, setComparisonType, setComparisonTypeModifier and TypeMethodDescriptionfinal intReturn the result by interrogating the implementation and applying a reverse sort if requred.intReturn the comparison type.String[]Return the list of comparison type names.voidsetComparisonType(int type) Sets the comparison type.voidsetComparisonType(String type) Sets the comparison type.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Comparator
equals, max, min, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
IATA
public static final int IATA- See Also:
-
ICAO
public static final int ICAO- See Also:
-
NAME
public static final int NAME- See Also:
-
LATITUDE
public static final int LATITUDE- See Also:
-
LONGITUDE
public static final int LONGITUDE- See Also:
-
-
Constructor Details
-
AirportComparator
public AirportComparator(int comparisonType) Creates a new AirportComparator with a given comparison type- Parameters:
comparisonType- The criteria by which to compare- Throws:
IllegalArgumentException- if the type is invalid- See Also:
-
AirportComparator
Creates a new AirportComparator with a given comparison type- Parameters:
comparisonType- The criteria name by which to compare- Throws:
IllegalArgumentException- if the type name is invalid- See Also:
-
-
Method Details
-
compareImpl
Compares two airports by the designated criteria- Specified by:
compareImplin classAbstractComparator<Airport>- Parameters:
a1- The first object to comparea2- The second object to compare- Returns:
- -1, 0, 1 as defined by the compareTo(Object, Object) interface
- Throws:
ClassCastException- if either object is not an Airport- See Also:
-