Class CitiesAndAirportsRegistry


  • public class CitiesAndAirportsRegistry
    extends java.lang.Object
    Represent an registry to store city and airports, singleton
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void add​(Airport a)
      Add an airport to the airport registry
      static void add​(City c)
      Add a city to the city registry
      static java.util.Collection<Airport> airports()
      Get a collection of airportId
      static java.util.Collection<City> cities()
      Get a collection of cityId
      static Airport get​(AirportId id)
      Get a airport from the airport registry
      static City get​(CityId code)
      Get a city from the city registry
      static CitiesAndAirportsRegistry getInstance()
      Singleton getInstance method.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getInstance

        public static CitiesAndAirportsRegistry getInstance()
        Singleton getInstance method.
        Returns:
        the instance of singleton
      • add

        public static void add​(City c)
        Add a city to the city registry
        Parameters:
        c - the city to add
        Throws:
        java.lang.IllegalArgumentException - on null parameter
      • add

        public static void add​(Airport a)
        Add an airport to the airport registry
        Parameters:
        a - the airport to add
        Throws:
        java.lang.IllegalArgumentException - on null parameter
      • get

        public static City get​(CityId code)
        Get a city from the city registry
        Parameters:
        code - the city identifier
        Throws:
        java.lang.IllegalArgumentException - on null parameter
      • get

        public static Airport get​(AirportId id)
        Get a airport from the airport registry
        Parameters:
        id - the airport identifier
        Throws:
        java.lang.IllegalArgumentException - on null parameter
      • cities

        public static java.util.Collection<City> cities()
        Get a collection of cityId
        Returns:
        a collection of city id
      • airports

        public static java.util.Collection<Airport> airports()
        Get a collection of airportId
        Returns:
        a collection of airport id