Class Country

java.lang.Object
proseccoCoding.TLN.model.Country

public class Country extends Object
This class represents a country with all its trusted providers (that provide services). Every country must be identified by its international code made of two characters.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private String
    String code that represent the country, must be in format "CC" both upper case
    private String
    Complete name of the country
    All the trusted providers that can be found in that country.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Country(String code, String name)
    Constructor for a country with specified name and code but without retrieved providers data
    Country(String code, String name, HashMap<String,Provider> providers)
    Constructor for a country with specified name and code but with retrieved providers data
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Adds the given provider to this country only if it isn't already added.
    Getter for country code
    Getter for country name
    getProvider(String providerCode)
    Returns the provider with the specified providerCode if there is one in this country
    Get the complete list of the providers based in this country or null if they have not already been retrieved The list would be empty if the providers are been retrieved but this country has no providers
    boolean
    States if the complete data of this country providers has already been retrieved.
    javafx.util.Pair<String,String>
    Returns a Pair of two String created as: (key=CountryCode, value=CountryName)

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • code

      private String code
      String code that represent the country, must be in format "CC" both upper case
    • name

      private String name
      Complete name of the country
    • providers

      private HashMap<String,Provider> providers
      All the trusted providers that can be found in that country. Stored as (Provider.code, Provider)
  • Constructor Details

    • Country

      public Country(String code, String name) throws IllegalArgumentException
      Constructor for a country with specified name and code but without retrieved providers data
      Parameters:
      code - 2 letter code that represents the country
      name - Complete name of the country
      Throws:
      IllegalArgumentException
    • Country

      public Country(String code, String name, HashMap<String,Provider> providers) throws IllegalArgumentException
      Constructor for a country with specified name and code but with retrieved providers data
      Parameters:
      code - Code that represents the country composed by 2 letters (upper or lower case)
      name - Complete name of the country
      providers - Complete collection of all providers based in this country
      Throws:
      IllegalArgumentException
  • Method Details

    • getProvider

      public Provider getProvider(String providerCode)
      Returns the provider with the specified providerCode if there is one in this country
      Parameters:
      providerCode - The code of the provider to get
      Returns:
      The provider if it's been found, null otherwise
    • addProvider

      public boolean addProvider(Provider provider) throws IllegalArgumentException
      Adds the given provider to this country only if it isn't already added.
      Parameters:
      provider - The provider to add to this country
      Returns:
      True if the provided has been added, false otherwise
      Throws:
      IllegalArgumentException - In case in which the provider is null or has a different countryCode
    • isRetrieved

      public boolean isRetrieved()
      States if the complete data of this country providers has already been retrieved. The complete data consists in all the providers and their associated data.
      Returns:
      True if the country provider data is been retrieved
    • print

      public javafx.util.Pair<String,String> print()
      Returns a Pair of two String created as: (key=CountryCode, value=CountryName)
      Returns:
      The pair of code and name representing this country
    • getProviders

      public ArrayList<Provider> getProviders()
      Get the complete list of the providers based in this country or null if they have not already been retrieved The list would be empty if the providers are been retrieved but this country has no providers
      Returns:
      The list containing all the providers or null if they have not already been retrieved
    • getCode

      public String getCode()
      Getter for country code
      Returns:
      The country code string
    • getName

      public String getName()
      Getter for country name
      Returns:
      The country name string