Package de.bcxp.challenge.countries
Class CountryAnalyser
java.lang.Object
de.bcxp.challenge.countries.CountryAnalyser
- All Implemented Interfaces:
IDocumentAnalyser
Analyzes a document of
CountryEntry
objects to extract the country with the highest population density.
Implements the IDocumentAnalyser
interface for CountryEntry
entries.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetBestMatches
(Document document) Finds the country with the highest population density from the provided document.
-
Field Details
-
logger
private static final org.apache.logging.log4j.Logger logger
-
-
Constructor Details
-
CountryAnalyser
public CountryAnalyser()Instantiates stateless analyser.
-
-
Method Details
-
getBestMatches
Finds the country with the highest population density from the provided document.This method analyzes the list of
CountryEntry
entries in the givenDocument
and returns the country with the maximum value of population density. If the list is empty, aNoSuchElementException
is thrown.- Specified by:
getBestMatches
in interfaceIDocumentAnalyser
- Parameters:
document
- the document containing a list ofCountryEntry
entries- Returns:
- A set of
CountryEntry
objects with the highest population density - Throws:
NoSuchElementException
- if the document contains no matching entries
-