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 Summary
Modifier and TypeMethodDescriptionAdd a way-point to the track-segment.addPoint(Consumer<? super WayPoint.Builder> point) Add a way-point to the track-segment, via the given way-point builder.build()Create a new track-segment from the current builder state.Return the current extensionsextensions(Document extensions) Sets the extensions object, which may benull.Return a filter consisting of the elements of this filter that matches the given predicate.Return a filter consisting of the results of replacing each element with the contents of the mapped elements.Return a filter with the results of the applying given mapper function.Return a filter with the results of applying the given mapper function.points()Return the current way-points.Set the way-points fo the track segment.
-
Method Details
-
points
Set the way-points fo the track segment. The list of way-points may benull.- Parameters:
points- the track-segment points- Returns:
thisBuilderfor method chaining- Throws:
NullPointerException- if one of the way-points in the list isnull
-
addPoint
Add a way-point to the track-segment.- Parameters:
point- the segment way-point- Returns:
thisBuilderfor method chaining- Throws:
NullPointerException- if the givenhrefisnull
-
addPoint
Add a way-point to the track-segment, via the given way-point builder.Creating a
TrackSegmentobject 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:
thisBuilderfor method chaining- Throws:
NullPointerException- if the givenhrefisnull
-
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 benull. The root element of the extensions document must beextensions.<extensions> ... </extensions>- Parameters:
extensions- the document- Returns:
thisBuilderfor method chaining- Throws:
IllegalArgumentException- if the root element is not the anextensionsnode- Since:
- 1.5
-
extensions
Return the current extensions- Returns:
- the extensions document
- Since:
- 1.5
-
filter
Description copied from interface:FilterReturn a filter consisting of the elements of this filter that matches the given predicate.- Specified by:
filterin interfaceFilter<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
Description copied from interface:FilterReturn a filter with the results of applying the given mapper function.- Specified by:
mapin interfaceFilter<WayPoint,TrackSegment> - Parameters:
mapper- a non-interfering, stateless function to apply to each element- Returns:
- a new filter
-
flatMap
Description copied from interface:FilterReturn a filter consisting of the results of replacing each element with the contents of the mapped elements.- Specified by:
flatMapin interfaceFilter<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:FilterReturn a filter with the results of the applying given mapper function.- Specified by:
listMapin interfaceFilter<WayPoint,TrackSegment> - Parameters:
mapper- a non-interfering, stateless function to apply to the existing elements- Returns:
- a new filter
-
build
Create a new track-segment from the current builder state.- Specified by:
buildin interfaceFilter<WayPoint,TrackSegment> - Returns:
- a new track-segment from the current builder state
-