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) voidsetElevation(BigDecimal elevation) voidsetLatitude(BigDecimal latitude) voidsetLocality(String locality) voidsetLongitude(BigDecimal longitude) voidvoidsetPostalCode(String postalCode) voidvoidsetStateOrProvince(String stateOrProvince) voidvoidsetTimeZoneId(String timeZoneId) 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
-
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
-
getRegion
Description copied from interface:LocationA country-specific regional identifier. -
setRegion
-
getStateOrProvince
Description copied from interface:LocationGet a country-specific state or province identifier.- Specified by:
getStateOrProvincein interfaceLocation- Returns:
- state or province identifier
-
setStateOrProvince
-
getLocality
Description copied from interface:LocationGet the locality (city, town, etc.).- Specified by:
getLocalityin interfaceLocation- Returns:
- locality
-
setLocality
-
getPostalCode
Description copied from interface:LocationGet a country-specific postal code.- Specified by:
getPostalCodein interfaceLocation- Returns:
- postal code
-
setPostalCode
-
getStreet
Description copied from interface:LocationGet the street address. -
setStreet
-
getLatitude
Description copied from interface:LocationGet the decimal latitude.- Specified by:
getLatitudein interfaceLocation- Returns:
- latitude
-
setLatitude
-
getLongitude
Description copied from interface:LocationGet the decimal longitude.- Specified by:
getLongitudein interfaceLocation- Returns:
- longitude
-
setLongitude
-
getElevation
Description copied from interface:LocationGet the elevation, in meters.- Specified by:
getElevationin interfaceLocation- Returns:
- the elevation
-
setElevation
-
getTimeZoneId
Description copied from interface:LocationGet a time zone ID, e.g.Pacific/Auckland.- Specified by:
getTimeZoneIdin interfaceLocation- Returns:
- a time zone ID
-
setTimeZoneId
-