Package gov.usgs.earthquake.nshmp.geo
Class LocationList.Builder
- java.lang.Object
-
- gov.usgs.earthquake.nshmp.geo.LocationList.Builder
-
- Enclosing interface:
- LocationList
public static final class LocationList.Builder extends Object
A reusableLocationList
builder. Repeat calls tobuild()
will return multiple lists in series with each new list containing all the elements of the one before it. Builder does not permit the addition ofnull
elements, however, null checking is lazy and not performed untilbuild()
is called.Use
LocationList.builder()
to create new builder instances.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LocationList.Builder
add(double longitude, double latitude)
Add a location with the specified longitude and latitude, and a depth of 0 km.LocationList.Builder
add(double longitude, double latitude, double depth)
Add a location with the specified longitude, latitude, and depth.LocationList.Builder
add(Location location)
Add a location.LocationList.Builder
add(Location... locations)
Add each of the supplied locations.LocationList.Builder
addAll(Collection<Location> locations)
Add each of the supplied locations.LocationList
build()
Return a newly createdLocationList
based on the contents of theBuilder
.
-
-
-
Method Detail
-
add
public LocationList.Builder add(Location location)
Add a location.- Parameters:
location
- to add- Returns:
- this
Builder
-
add
public LocationList.Builder add(double longitude, double latitude)
Add a location with the specified longitude and latitude, and a depth of 0 km.- Parameters:
longitude
- in decimal degreeslatitude
- in decimal degrees- Returns:
- this
Builder
- Throws:
IllegalArgumentException
- if any values are out of range- See Also:
Coordinates
-
add
public LocationList.Builder add(double longitude, double latitude, double depth)
Add a location with the specified longitude, latitude, and depth.- Parameters:
longitude
- in decimal degreeslatitude
- in decimal degreesdepth
- in km (positive down)- Returns:
- this
Builder
- Throws:
IllegalArgumentException
- if any values are out of range- See Also:
Coordinates
-
add
public LocationList.Builder add(Location... locations)
Add each of the supplied locations.- Parameters:
locations
- to add- Returns:
- this
Builder
-
addAll
public LocationList.Builder addAll(Collection<Location> locations)
Add each of the supplied locations.- Parameters:
locations
- to add- Returns:
- this
Builder
-
build
public LocationList build()
Return a newly createdLocationList
based on the contents of theBuilder
.- Returns:
- a new
LocationList
- Throws:
IllegalStateException
- if the list is emptyNullPointerException
- if the list containsnull
elements
-
-