Package net.solarnetwork.domain
Class SimpleLocation
java.lang.Object
net.solarnetwork.domain.SimpleLocation
- All Implemented Interfaces:
Serializable,Cloneable,Location
Simple, mutable implementation of
Location.- Since:
- 1.67
- Version:
- 1.1
- Author:
- matt
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.SimpleLocation(Location loc) Copy constructor forLocationobjects. -
Method Summary
Modifier and TypeMethodDescriptionclone()booleanGet the ISO 3166-1 alpha-2 character country code.Get the elevation, in meters.Get the decimal latitude.Get the locality (city, town, etc.).Get the decimal longitude.getName()A generalized name, can be used for "virtual" locations.Get a country-specific postal code.A country-specific regional identifier.Get a country-specific state or province identifier.Get the street address.Get a time zone ID, e.g.inthashCode()static SimpleLocationlocationOf(String country, String region, String timeZoneId) Create a new location instance.static SimpleLocationlocationOf(String name, String country, String region, String stateOrProvince, String locality, String postalCode, String street, String timeZoneId) Create a new location instance.static SimpleLocationlocationValue(Location location) Get aSimpleLocationfor aLocation.static SimpleLocationReturn a new SolarLocation with normalized values from another Location.voidChange values that are non-null but empty to null.voidsetCountry(String country) Set the country.voidsetElevation(BigDecimal elevation) Set the elevation.voidsetLatitude(BigDecimal latitude) Set the latitude.voidsetLocality(String locality) Set the locality.voidsetLongitude(BigDecimal longitude) Set the longitude.voidSet the name.voidsetPostalCode(String postalCode) Set the postal code.voidSet the region.voidsetStateOrProvince(String stateOrProvince) Set the state or province.voidSet the street.voidsetTimeZoneId(String timeZoneId) Set the time zone ID.toString()Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.solarnetwork.domain.Location
hasLocationCriteria
-
Constructor Details
-
SimpleLocation
public SimpleLocation()Default constructor. -
SimpleLocation
Copy constructor forLocationobjects.- 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 namecountry- the countryregion- the regionstateOrProvince- the state or provincelocality- the locality (city)postalCode- the postal codestreet- the streettimeZoneId- the time zone ID- Returns:
- the new location instance
-
locationOf
Create a new location instance.- Parameters:
country- the countryregion- the regiontimeZoneId- the time zone ID- Returns:
- the new location instance
-
clone
-
hashCode
public int hashCode() -
equals
-
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
Return a new SolarLocation with normalized values from another Location.- Parameters:
loc- the location to normalize- Returns:
- the normalized location
-
locationValue
Get aSimpleLocationfor aLocation.Note if
locationis already aSimpleLocationthen it will be returned via a cast. Otherwise a new instance will be created.- Parameters:
location- the location to get as aSimpleLocation- Returns:
- the
SimpleLocationinstance, or null iflocationis null - Since:
- 1.1
-
toString
-
getName
Description copied from interface:LocationA generalized name, can be used for "virtual" locations. -
setName
Set the name.- Parameters:
name- the name to set
-
getCountry
Description copied from interface:LocationGet the ISO 3166-1 alpha-2 character country code.- Specified by:
getCountryin interfaceLocation- Returns:
- 2-character country code
-
setCountry
Set the country.- Parameters:
country- the country to set
-
getRegion
Description copied from interface:LocationA country-specific regional identifier. -
setRegion
Set the region.- Parameters:
region- the region to set
-
getStateOrProvince
Description copied from interface:LocationGet a country-specific state or province identifier.- Specified by:
getStateOrProvincein interfaceLocation- Returns:
- state or province identifier
-
setStateOrProvince
Set the state or province.- Parameters:
stateOrProvince- the state to set
-
getLocality
Description copied from interface:LocationGet the locality (city, town, etc.).- Specified by:
getLocalityin interfaceLocation- Returns:
- locality
-
setLocality
Set the locality.- Parameters:
locality- the locality to set
-
getPostalCode
Description copied from interface:LocationGet a country-specific postal code.- Specified by:
getPostalCodein interfaceLocation- Returns:
- postal code
-
setPostalCode
Set the postal code.- Parameters:
postalCode- the postal code to set
-
getStreet
Description copied from interface:LocationGet the street address. -
setStreet
Set the street.- Parameters:
street- the street to set
-
getLatitude
Description copied from interface:LocationGet the decimal latitude.- Specified by:
getLatitudein interfaceLocation- Returns:
- latitude
-
setLatitude
Set the latitude.- Parameters:
latitude- the latitude to set
-
getLongitude
Description copied from interface:LocationGet the decimal longitude.- Specified by:
getLongitudein interfaceLocation- Returns:
- longitude
-
setLongitude
Set the longitude.- Parameters:
longitude- the longitude to set
-
getElevation
Description copied from interface:LocationGet the elevation, in meters.- Specified by:
getElevationin interfaceLocation- Returns:
- the elevation
-
setElevation
Set the elevation.- Parameters:
elevation- the elevation to set
-
getTimeZoneId
Description copied from interface:LocationGet a time zone ID, e.g.Pacific/Auckland.- Specified by:
getTimeZoneIdin interfaceLocation- Returns:
- a time zone ID
-
setTimeZoneId
Set the time zone ID.- Parameters:
timeZoneId- the ID to set
-