Class SimpleLocation

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

public class SimpleLocation extends Object implements Location, Cloneable, Serializable
Simple, mutable implementation of Location.
Since:
1.67
Version:
1.1
Author:
matt
See Also:
  • Constructor Details

    • SimpleLocation

      public SimpleLocation()
      Default constructor.
    • SimpleLocation

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

    • locationOf

      public static SimpleLocation 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 SimpleLocation 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 SimpleLocation 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
    • removeEmptyValues

      public void removeEmptyValues()
      Change values that are non-null but empty to null.

      This method is helpful for web form submission, to remove filter values that are empty and would otherwise try to match on empty string values.

    • normalizedLocation

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

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

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

      Parameters:
      location - the location to get as a SimpleLocation
      Returns:
      the SimpleLocation 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
    • setName

      public void setName(String 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
    • setCountry

      public void setCountry(String country)
    • getRegion

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

      public void setRegion(String region)
    • 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
    • setStateOrProvince

      public void setStateOrProvince(String stateOrProvince)
    • getLocality

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

      public void setLocality(String 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
    • setPostalCode

      public void setPostalCode(String postalCode)
    • getStreet

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

      public void setStreet(String street)
    • getLatitude

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

      public void setLatitude(BigDecimal latitude)
    • getLongitude

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

      public void setLongitude(BigDecimal longitude)
    • getElevation

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

      public void setElevation(BigDecimal 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
    • setTimeZoneId

      public void setTimeZoneId(String timeZoneId)