Package com.uca.flights
Class CitiesAndAirportsRegistry
- java.lang.Object
-
- com.uca.flights.CitiesAndAirportsRegistry
-
public class CitiesAndAirportsRegistry extends java.lang.ObjectRepresent an registry to store city and airports, singleton
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidadd(Airport a)Add an airport to the airport registrystatic voidadd(City c)Add a city to the city registrystatic java.util.Collection<Airport>airports()Get a collection of airportIdstatic java.util.Collection<City>cities()Get a collection of cityIdstatic Airportget(AirportId id)Get a airport from the airport registrystatic Cityget(CityId code)Get a city from the city registrystatic CitiesAndAirportsRegistrygetInstance()Singleton getInstance method.
-
-
-
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
-
-