Class City


  • public class City
    extends java.lang.Object
    Represent an city
    • Constructor Summary

      Constructors 
      Constructor Description
      City​(CityId code, java.lang.String name)
      Constructor
    • Constructor Detail

      • City

        public City​(CityId code,
                    java.lang.String name)
        Constructor
        Parameters:
        code - a city code
        name - the city name
        Throws:
        java.lang.IllegalArgumentException - on null or empty parameter
    • Method Detail

      • getName

        public java.lang.String getName()
        Getter
        Returns:
        city name
      • setName

        public void setName​(java.lang.String name)
        Setter
        Parameters:
        name - the city name
        Throws:
        java.lang.IllegalArgumentException - on null or empty parameter
      • getCode

        public CityId getCode()
        Getter
        Returns:
        city identifier
      • addAirport

        public void addAirport​(Airport airport)
        Add a airport to the city set of airport
        Parameters:
        airport - the airport to add, warning on already existing airport
        Throws:
        java.lang.IllegalArgumentException - on null parameter
      • removeAirport

        public void removeAirport​(Airport airport)
        Remove an airport from the city set of airport
        Parameters:
        airport - the airport to remove
        Throws:
        java.lang.IllegalArgumentException - on null, non existing or main city parameter
      • getAirports

        public java.util.Set<Airport> getAirports()
        Getter
        Returns:
        city set of airports
      • toString

        public java.lang.String toString()
        Redefinition of toString
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string with name and identifier
      • equals

        public boolean equals​(java.lang.Object other)
        Redefinition of equals
        Overrides:
        equals in class java.lang.Object
        Parameters:
        other - the city to compare to
        Returns:
        true if other has the same identifier, false else
        Throws:
        java.lang.IllegalArgumentException - on null or not city parameter
      • hashCode

        public int hashCode()
        Redefinition of hashCode
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hashcode