Package proseccoCoding.TLN.model
Class Country
java.lang.Object
proseccoCoding.TLN.model.Country
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 -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for a country with specified name and code but without retrieved providers dataConstructor for a country with specified name and code but with retrieved providers data -
Method Summary
Modifier and TypeMethodDescriptionboolean
addProvider
(Provider provider) Adds the given provider to this country only if it isn't already added.getCode()
Getter for country codegetName()
Getter for country namegetProvider
(String providerCode) Returns the provider with the specified providerCode if there is one in this countryGet 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 providersboolean
States if the complete data of this country providers has already been retrieved.print()
Returns a Pair of two String created as: (key=CountryCode, value=CountryName)
-
Field Details
-
code
String code that represent the country, must be in format "CC" both upper case -
name
Complete name of the country -
providers
All the trusted providers that can be found in that country. Stored as (Provider.code, Provider)
-
-
Constructor Details
-
Country
Constructor for a country with specified name and code but without retrieved providers data- Parameters:
code
- 2 letter code that represents the countryname
- Complete name of the country- Throws:
IllegalArgumentException
-
Country
public Country(String code, String name, HashMap<String, Provider> providers) throws IllegalArgumentExceptionConstructor 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 countryproviders
- Complete collection of all providers based in this country- Throws:
IllegalArgumentException
-
-
Method Details
-
getProvider
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
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
Returns a Pair of two String created as: (key=CountryCode, value=CountryName)- Returns:
- The pair of code and name representing this country
-
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
Getter for country code- Returns:
- The country code string
-
getName
Getter for country name- Returns:
- The country name string
-