Class CountryEntry

java.lang.Object
de.bcxp.challenge.common.model.DocumentEntry
de.bcxp.challenge.countries.CountryEntry
All Implemented Interfaces:
IEntryWithComparableNumericTuple

public class CountryEntry extends DocumentEntry implements IEntryWithComparableNumericTuple
Represents a data entry for a specific country.

This class extends DocumentEntry and adds population and area-specific information.

See Also:
  • 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

      public CountryEntry(String country, long population, double area)
      Constructs a CountryEntry object.
      Parameters:
      country - the name or identifier of the country
      population - 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 - if population is negative, or if area 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 interface IEntryWithComparableNumericTuple
      Returns:
      the population density as a double
      Throws:
      IllegalStateException - if the area is zero, indicating an invalid object state
    • getCountry

      public String getCountry()
    • getArea

      public double getArea()
    • getPopulation

      public long getPopulation()
    • toString

      public String toString()
      Overrides:
      toString in class Object