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 reusable LocationList builder. Repeat calls to build() 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 of null elements, however, null checking is lazy and not performed until build() is called.

Use LocationList.builder() to create new builder instances.

  • Method Details

    • 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 degrees
      latitude - in decimal degrees
      Returns:
      this Builder
      Throws:
      IllegalArgumentException - if any values are out of range
      See Also:
    • 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 degrees
      latitude - in decimal degrees
      depth - in km (positive down)
      Returns:
      this Builder
      Throws:
      IllegalArgumentException - if any values are out of range
      See Also:
    • 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 created LocationList based on the contents of the Builder.
      Returns:
      a new LocationList
      Throws:
      IllegalStateException - if the list is empty
      NullPointerException - if the list contains null elements