Package de.bcxp.challenge.countries
Class CountryEntry
java.lang.Object
de.bcxp.challenge.common.model.DocumentEntry
de.bcxp.challenge.countries.CountryEntry
- All Implemented Interfaces:
IEntryWithComparableNumericTuple
Represents a data entry for a specific country.
This class extends DocumentEntry
and adds population and area-specific information.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final double
private static final org.apache.logging.log4j.Logger
private final long
-
Constructor Summary
ConstructorsConstructorDescriptionCountryEntry
(String country, long population, double area) Constructs aCountryEntry
object. -
Method Summary
Methods inherited from class de.bcxp.challenge.common.model.DocumentEntry
getId
-
Field Details
-
logger
private static final org.apache.logging.log4j.Logger logger -
population
private final long population -
area
private final double area
-
-
Constructor Details
-
CountryEntry
Constructs aCountryEntry
object.- Parameters:
country
- the name or identifier of the countrypopulation
- the population count of the country (must be zero or positive)area
- the total area of the country in square units (must be greater than zero)- Throws:
IllegalArgumentException
- ifpopulation
is negative, or ifarea
is less than or equal to zero
-
-
Method Details
-
getBestMatchScore
public double getBestMatchScore()Calculates and returns the population density for this country instance.- Specified by:
getBestMatchScore
in interfaceIEntryWithComparableNumericTuple
- Returns:
- the population density as a
double
- Throws:
IllegalStateException
- if the area is zero, indicating an invalid object state
-
getCountry
-
getArea
public double getArea() -
getPopulation
public long getPopulation() -
toString
-