Class CountryComparator
- All Implemented Interfaces:
Serializable, Comparator<Country>
A Comparator for Country beans.
- Since:
- 3.2
- Version:
- 7.0
- Author:
- Luke
- See Also:
-
Field Summary
FieldsFields 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
ConstructorsConstructorDescriptionCountryComparator(int comparisonType) Creates a new CountryComparator with a given comparison type.CountryComparator(String comparisonType) Creates a new CountryComparator with a given comparison type. -
Method Summary
Modifier and TypeMethodDescriptionintcompareImpl(Country c1, Country c2) Compares two countries by the designated criteria.Methods 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
-
CODE
public static final int CODE- See Also:
-
NAME
public static final int NAME- See Also:
-
-
Constructor Details
-
CountryComparator
public CountryComparator(int comparisonType) Creates a new CountryComparator with a given comparison type.- Parameters:
comparisonType- The criteria by which to compare- Throws:
IllegalArgumentException- if the type is invalid- See Also:
-
CountryComparator
Creates a new CountryComparator with a given comparison type.- Parameters:
comparisonType- The criteria type name by which to compare- Throws:
IllegalArgumentException- if the type name is invalid- See Also:
-
-
Method Details
-
compareImpl
Compares two countries by the designated criteria.- Specified by:
compareImplin classAbstractComparator<Country>- Parameters:
c1- The first object to comparec2- The second object to compare- Returns:
- -1, 0, 1 as defined by the compareTo(Object, Object) interface
- See Also:
-