Class TrackSegment.Builder

java.lang.Object
io.jenetics.jpx.TrackSegment.Builder
All Implemented Interfaces:
Filter<WayPoint,TrackSegment>
Enclosing class:
TrackSegment

public static final class TrackSegment.Builder extends Object implements Filter<WayPoint,TrackSegment>
Builder class for creating immutable TrackSegment objects.

Creating a TrackSegment object with 3 track-points:

final TrackSegment segment = TrackSegment.builder() .addPoint(p -> p.lat(48.2081743).lon(16.3738189).ele(160)) .addPoint(p -> p.lat(48.2081743).lon(16.3738189).ele(161)) .addPoint(p -> p.lat(48.2081743).lon(16.3738189).ele(162)))) .build();
  • Method Details

    • points

      Set the way-points fo the track segment. The list of way-points may be null.
      Parameters:
      points - the track-segment points
      Returns:
      this Builder for method chaining
      Throws:
      NullPointerException - if one of the way-points in the list is null
    • addPoint

      Add a way-point to the track-segment.
      Parameters:
      point - the segment way-point
      Returns:
      this Builder for method chaining
      Throws:
      NullPointerException - if the given href is null
    • addPoint

      Add a way-point to the track-segment, via the given way-point builder.

      Creating a TrackSegment object with 3 track-points:

      final TrackSegment segment = TrackSegment.builder() .addPoint(p -> p.lat(48.2081743).lon(16.3738189).ele(160)) .addPoint(p -> p.lat(48.2081743).lon(16.3738189).ele(161)) .addPoint(p -> p.lat(48.2081743).lon(16.3738189).ele(162)))) .build();
      Parameters:
      point - the segment way-point builder
      Returns:
      this Builder for method chaining
      Throws:
      NullPointerException - if the given href is null
    • points

      public List<WayPoint> points()
      Return the current way-points. The returned list is mutable.
      Returns:
      the current, mutable way-point list
      Since:
      1.1
    • extensions

      Sets the extensions object, which may be null. The root element of the extensions document must be extensions.
      <extensions> ... </extensions>
      Parameters:
      extensions - the document
      Returns:
      this Builder for method chaining
      Throws:
      IllegalArgumentException - if the root element is not the an extensions node
      Since:
      1.5
    • extensions

      Return the current extensions
      Returns:
      the extensions document
      Since:
      1.5
    • filter

      public TrackSegment.Builder filter(Predicate<? super WayPoint> predicate)
      Description copied from interface: Filter
      Return a filter consisting of the elements of this filter that matches the given predicate.
      Specified by:
      filter in interface Filter<WayPoint,TrackSegment>
      Parameters:
      predicate - a non-interfering, stateless predicate to apply to each element to determine if it should be included
      Returns:
      a new filter
    • map

      public TrackSegment.Builder map(Function<? super WayPoint,? extends WayPoint> mapper)
      Description copied from interface: Filter
      Return a filter with the results of applying the given mapper function.
      Specified by:
      map in interface Filter<WayPoint,TrackSegment>
      Parameters:
      mapper - a non-interfering, stateless function to apply to each element
      Returns:
      a new filter
    • flatMap

      public TrackSegment.Builder flatMap(Function<? super WayPoint,? extends List<WayPoint>> mapper)
      Description copied from interface: Filter
      Return a filter consisting of the results of replacing each element with the contents of the mapped elements.
      Specified by:
      flatMap in interface Filter<WayPoint,TrackSegment>
      Parameters:
      mapper - a non-interfering, stateless function to apply to each element which produces a list of new values
      Returns:
      a new filter
    • listMap

      public TrackSegment.Builder listMap(Function<? super List<WayPoint>,? extends List<WayPoint>> mapper)
      Description copied from interface: Filter
      Return a filter with the results of the applying given mapper function.
      Specified by:
      listMap in interface Filter<WayPoint,TrackSegment>
      Parameters:
      mapper - a non-interfering, stateless function to apply to the existing elements
      Returns:
      a new filter
    • build

      public TrackSegment build()
      Create a new track-segment from the current builder state.
      Specified by:
      build in interface Filter<WayPoint,TrackSegment>
      Returns:
      a new track-segment from the current builder state