Package net.solarnetwork.domain
Class BasicLocation
java.lang.Object
net.solarnetwork.domain.BasicLocation
- All Implemented Interfaces:
Serializable,Cloneable,Location
Basic, immutable implementation of
Location.- Version:
- 1.2
- Author:
- matt
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBasicLocation(String name, String country, String region, String stateOrProvince, String locality, String postalCode, String street, BigDecimal latitude, BigDecimal longitude, BigDecimal elevation, String timeZoneId) Constructor.BasicLocation(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 BasicLocationlocationOf(String country, String region, String timeZoneId) Create a new location instance.static BasicLocationlocationOf(String name, String country, String region, String stateOrProvince, String locality, String postalCode, String street, String timeZoneId) Create a new location instance.static BasicLocationlocationValue(Location location) Get aBasicLocationfor aLocation.static BasicLocationReturn a new BasicLocation with normalized values from another Location.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
-
BasicLocation
Copy constructor forLocationobjects.- 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 namecountry- the countryregion- the regionstateOrProvince- the state or provincelocality- the locality (city)postalCode- the postal codestreet- the streetlatitude- the latitudelongitude- the longitudeelevation- the elevationtimeZoneId- 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 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
-
normalizedLocation
Return a new BasicLocation with normalized values from another Location.- Parameters:
loc- the location to normalize- Returns:
- the normalized location
-
locationValue
Get aBasicLocationfor aLocation.Note if
locationis already aBasicLocationthen it will be returned via a cast. Otherwise a new instance will be created.- Parameters:
location- the location to get as aBasicLocation- Returns:
- the
BasicLocationinstance, or null iflocationis null - Since:
- 1.1
-
toString
-
getName
Description copied from interface:LocationA generalized name, can be used for "virtual" locations. -
getCountry
Description copied from interface:LocationGet the ISO 3166-1 alpha-2 character country code.- Specified by:
getCountryin interfaceLocation- Returns:
- 2-character country code
-
getRegion
Description copied from interface:LocationA country-specific regional identifier. -
getStateOrProvince
Description copied from interface:LocationGet a country-specific state or province identifier.- Specified by:
getStateOrProvincein interfaceLocation- Returns:
- state or province identifier
-
getLocality
Description copied from interface:LocationGet the locality (city, town, etc.).- Specified by:
getLocalityin interfaceLocation- Returns:
- locality
-
getPostalCode
Description copied from interface:LocationGet a country-specific postal code.- Specified by:
getPostalCodein interfaceLocation- Returns:
- postal code
-
getStreet
Description copied from interface:LocationGet the street address. -
getLatitude
Description copied from interface:LocationGet the decimal latitude.- Specified by:
getLatitudein interfaceLocation- Returns:
- latitude
-
getLongitude
Description copied from interface:LocationGet the decimal longitude.- Specified by:
getLongitudein interfaceLocation- Returns:
- longitude
-
getElevation
Description copied from interface:LocationGet the elevation, in meters.- Specified by:
getElevationin interfaceLocation- Returns:
- the elevation
-
getTimeZoneId
Description copied from interface:LocationGet a time zone ID, e.g.Pacific/Auckland.- Specified by:
getTimeZoneIdin interfaceLocation- Returns:
- a time zone ID
-