Class Provider

java.lang.Object
proseccoCoding.TLN.model.Provider

public class Provider extends Object
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 Details

    • name

      private String name
      Provider complete name
    • code

      private String code
      Custom code made as code = countryCode-counter
    • counter

      private static int counter
      Static counter to implement the incremental assignment of codes
    • country

      private Country country
      The country in which this provider is located
    • services

      private com.google.common.collect.SetMultimap<ServiceType,Service> services
      Multimap that stores the services as value and the related type as key
  • Constructor Details

    • Provider

      public Provider(String name, Country country) throws IllegalArgumentException
      Constructor for class Provider
      Parameters:
      name - Complete name of the provider
      country - Object of the provider country, should be the effective object that contains this provider
      Throws:
      IllegalArgumentException
  • Method Details

    • addService

      public boolean addService(Service service) throws IllegalArgumentException
      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

      public ArrayList<Service> getServices(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.
      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

      public ArrayList<ServiceType> 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

      public boolean equals(Object obj)
      Checks if the object passed as argument is equal to this object only by comparing their codes
      Overrides:
      equals in class Object
    • getName

      public String getName()
      Getter for provider name
      Returns:
      The provider name string
    • getCode

      public String getCode()
      Getter for provider code
      Returns:
      The provider code string
    • getCountry

      public Country getCountry()
      Getter for provider country
      Returns:
      The provider country object
    • getCountryCodeBy

      public static String getCountryCodeBy(String providerCode) throws IllegalArgumentException
      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

      public static boolean isProviderCodeLegal(String providerCode) throws IllegalArgumentException
      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