Package proseccoCoding.TLN.model
Class Provider
java.lang.Object
proseccoCoding.TLN.model.Provider
This class represents a provider of trusted services. It includes name, code, country and its services.\n
It is recommended to not instantiate the Country object in the constructor of the Provider, but to
pass the effective Country object that contains this Provider. This parameter is used as
additional info and to generate the provider code.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
Custom code made as code = countryCode-counterprivate static int
Static counter to implement the incremental assignment of codesprivate Country
The country in which this provider is locatedprivate String
Provider complete nameprivate com.google.common.collect.SetMultimap<ServiceType,
Service> Multimap that stores the services as value and the related type as key -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
addService
(Service service) Adds the service to the providerboolean
Checks if the object passed as argument is equal to this object only by comparing their codesgetCode()
Getter for provider codeGetter for provider countrystatic String
getCountryCodeBy
(String providerCode) Static method that returns the country code associated to the given provider code.getName()
Getter for provider namegetServices
(ServiceType type) Returns all the services saved in the services Multimap that have a service type as value that equals the one given as parameter.Returns all the service types provided by this provider.static boolean
isProviderCodeLegal
(String providerCode) Static method that checks if the provider code is legal.
-
Field Details
-
name
Provider complete name -
code
Custom code made as code = countryCode-counter -
counter
private static int counterStatic counter to implement the incremental assignment of codes -
country
The country in which this provider is located -
services
Multimap that stores the services as value and the related type as key
-
-
Constructor Details
-
Provider
Constructor for class Provider- Parameters:
name
- Complete name of the providercountry
- Object of the provider country, should be the effective object that contains this provider- Throws:
IllegalArgumentException
-
-
Method Details
-
addService
Adds the service to the provider- Parameters:
service
- The service to add- Returns:
- True if the service has been added successfully, false otherwise
- Throws:
IllegalArgumentException
- if the service is null
-
getServices
Returns all the services saved in the services Multimap that have a service type as value that equals the one given as parameter.- Parameters:
type
- The service type to search for- Returns:
- ArrayList of services if there are with the given service type, or empty (not null) if there aren't
-
getServiceTypes
Returns all the service types provided by this provider. If this provider has no services, the ArrayList will be empty (not null).- Returns:
- An ArrayList containing all service types without duplicates
-
equals
Checks if the object passed as argument is equal to this object only by comparing their codes -
getName
Getter for provider name- Returns:
- The provider name string
-
getCode
Getter for provider code- Returns:
- The provider code string
-
getCountry
Getter for provider country- Returns:
- The provider country object
-
getCountryCodeBy
Static method that returns the country code associated to the given provider code. The provider code must be as [A-Z]{2}-[0-9]{1,}- Parameters:
providerCode
- The code of the provider- Returns:
- The code of the country in which the provider is located
- Throws:
IllegalArgumentException
- if the given code is not in a legal format
-
isProviderCodeLegal
Static method that checks if the provider code is legal. The provider code must be as [A-Z]{2}-[0-9]{1,}- Parameters:
providerCode
- The code of the provider- Returns:
- True if the code is correctly formatted
- Throws:
IllegalArgumentException
- if the given code is null
-