Class BasicLocation

java.lang.Object
net.solarnetwork.domain.BasicLocation
All Implemented Interfaces:
Serializable, Cloneable, Location

public class BasicLocation extends Object implements Location, Cloneable, Serializable
Basic, immutable implementation of Location.
Version:
1.2
Author:
matt
See Also:
  • Constructor Details

    • BasicLocation

      public BasicLocation(Location loc)
      Copy constructor for Location objects.
      Parameters:
      loc - the location to copy
    • BasicLocation

      public BasicLocation(String name, String country, String region, String stateOrProvince, String locality, String postalCode, String street, BigDecimal latitude, BigDecimal longitude, BigDecimal elevation, String timeZoneId)
      Constructor.
      Parameters:
      name - the name
      country - the country
      region - the region
      stateOrProvince - the state or province
      locality - the locality (city)
      postalCode - the postal code
      street - the street
      latitude - the latitude
      longitude - the longitude
      elevation - the elevation
      timeZoneId - the time zone ID
  • Method Details

    • locationOf

      public static BasicLocation locationOf(String name, String country, String region, String stateOrProvince, String locality, String postalCode, String street, String timeZoneId)
      Create a new location instance.
      Parameters:
      name - the name
      country - the country
      region - the region
      stateOrProvince - the state or province
      locality - the locality (city)
      postalCode - the postal code
      street - the street
      timeZoneId - the time zone ID
      Returns:
      the new location instance
    • locationOf

      public static BasicLocation locationOf(String country, String region, String timeZoneId)
      Create a new location instance.
      Parameters:
      country - the country
      region - the region
      timeZoneId - the time zone ID
      Returns:
      the new location instance
    • clone

      public BasicLocation clone()
      Overrides:
      clone in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • normalizedLocation

      public static BasicLocation normalizedLocation(Location loc)
      Return a new BasicLocation with normalized values from another Location.
      Parameters:
      loc - the location to normalize
      Returns:
      the normalized location
    • locationValue

      public static BasicLocation locationValue(Location location)
      Get a BasicLocation for a Location.

      Note if location is already a BasicLocation then it will be returned via a cast. Otherwise a new instance will be created.

      Parameters:
      location - the location to get as a BasicLocation
      Returns:
      the BasicLocation instance, or null if location is null
      Since:
      1.1
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getName

      public String getName()
      Description copied from interface: Location
      A generalized name, can be used for "virtual" locations.
      Specified by:
      getName in interface Location
      Returns:
      the location name
    • getCountry

      public String getCountry()
      Description copied from interface: Location
      Get the ISO 3166-1 alpha-2 character country code.
      Specified by:
      getCountry in interface Location
      Returns:
      2-character country code
    • getRegion

      public String getRegion()
      Description copied from interface: Location
      A country-specific regional identifier.
      Specified by:
      getRegion in interface Location
      Returns:
      region identifier
    • getStateOrProvince

      public String getStateOrProvince()
      Description copied from interface: Location
      Get a country-specific state or province identifier.
      Specified by:
      getStateOrProvince in interface Location
      Returns:
      state or province identifier
    • getLocality

      public String getLocality()
      Description copied from interface: Location
      Get the locality (city, town, etc.).
      Specified by:
      getLocality in interface Location
      Returns:
      locality
    • getPostalCode

      public String getPostalCode()
      Description copied from interface: Location
      Get a country-specific postal code.
      Specified by:
      getPostalCode in interface Location
      Returns:
      postal code
    • getStreet

      public String getStreet()
      Description copied from interface: Location
      Get the street address.
      Specified by:
      getStreet in interface Location
      Returns:
      street
    • getLatitude

      public BigDecimal getLatitude()
      Description copied from interface: Location
      Get the decimal latitude.
      Specified by:
      getLatitude in interface Location
      Returns:
      latitude
    • getLongitude

      public BigDecimal getLongitude()
      Description copied from interface: Location
      Get the decimal longitude.
      Specified by:
      getLongitude in interface Location
      Returns:
      longitude
    • getElevation

      public BigDecimal getElevation()
      Description copied from interface: Location
      Get the elevation, in meters.
      Specified by:
      getElevation in interface Location
      Returns:
      the elevation
    • getTimeZoneId

      public String getTimeZoneId()
      Description copied from interface: Location
      Get a time zone ID, e.g. Pacific/Auckland.
      Specified by:
      getTimeZoneId in interface Location
      Returns:
      a time zone ID