java.lang.Object
io.jenetics.jpx.Track.Builder
- All Implemented Interfaces:
Filter<TrackSegment,Track>
- Enclosing class:
- Track
Builder class for creating immutable
Track objects.
Creating a Track object with one track-segment and 3 track-points:
final Track track = Track.builder()
.name("Track 1")
.description("Mountain bike tour.")
.addSegment(segment -> segment
.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))))
.addSegment(segment -> segment
.addPoint(p -> p.lat(46.2081743).lon(16.3738189).ele(160))
.addPoint(p -> p.lat(47.2081743).lon(16.3738189).ele(161))
.addPoint(p -> p.lat(49.2081743).lon(16.3738189).ele(162))))
.build();-
Method Summary
Modifier and TypeMethodDescriptionAdd the givenlinkto the trackAdd the givenlinkto the trackaddSegment(TrackSegment segment) Add a track segment to the track.addSegment(Consumer<? super TrackSegment.Builder> segment) Add a track segment to the track, via the given builder.build()Create a new GPX track from the current builder state.cmt()Set the comment of the track.desc()Return the current description value.Set the description of the track.Return the current extensionsextensions(Document extensions) Sets the extensions object, which may benull.filter(Predicate<? super TrackSegment> predicate) Return a filter consisting of the elements of this filter that matches the given predicate.flatMap(Function<? super TrackSegment, ? extends List<TrackSegment>> mapper) Return a filter consisting of the results of replacing each element with the contents of the mapped elements.links()Return the current links.Set the track links.listMap(Function<? super List<TrackSegment>, ? extends List<TrackSegment>> mapper) Return a filter with the results of the applying given mapper function.map(Function<? super TrackSegment, ? extends TrackSegment> mapper) Return a filter with the results of applying the given mapper function.name()Return the current name value.Set the name of the track.number()Return the current number value.number(int number) Set the track number.Set the track number.segments()Return the current track segments.segments(List<TrackSegment> segments) Set the track segments of the track.src()Return the current source value.Set the source of the track.type()Return the current type value.Set the track type.
-
Method Details
-
name
Set the name of the track.- Parameters:
name- the track name- Returns:
thisBuilderfor method chaining
-
name
Return the current name value.- Returns:
- the current name value
- Since:
- 1.1
-
cmt
Set the comment of the track.- Parameters:
comment- the track comment- Returns:
thisBuilderfor method chaining
-
cmt
-
desc
Set the description of the track.- Parameters:
description- the track description- Returns:
thisBuilderfor method chaining
-
desc
Return the current description value.- Returns:
- the current description value
- Since:
- 1.1
-
src
Set the source of the track.- Parameters:
source- the track source- Returns:
thisBuilderfor method chaining
-
src
Return the current source value.- Returns:
- the current source value
- Since:
- 1.1
-
links
Set the track links. The link list may benull.- Parameters:
links- the track links- Returns:
thisBuilderfor method chaining- Throws:
NullPointerException- if one of the links in the list isnull
-
addLink
Add the givenlinkto the track- Parameters:
link- the link to add to the track- Returns:
thisBuilderfor method chaining
-
addLink
Add the givenlinkto the track- Parameters:
href- the link to add to the track- Returns:
thisBuilderfor method chaining- Throws:
NullPointerException- if the givenhrefisnullIllegalArgumentException- if the givenhrefis not a valid URL
-
links
Return the current links. The returned link list is mutable.- Returns:
- the current links
- Since:
- 1.1
-
number
Set the track number.- Parameters:
number- the track number- Returns:
thisBuilderfor method chaining
-
number
Set the track number.- Parameters:
number- the track number- Returns:
thisBuilderfor method chaining- Throws:
IllegalArgumentException- if the givenvalueis smaller than zero
-
number
Return the current number value.- Returns:
- the current number value
- Since:
- 1.1
-
type
Set the track type.- Parameters:
type- the track type- Returns:
thisBuilderfor method chaining
-
type
Return the current type value.- Returns:
- the current type value
- 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
-
segments
Set the track segments of the track. The list may benull.- Parameters:
segments- the track segments- Returns:
thisBuilderfor method chaining- Throws:
NullPointerException- if one of the segments in the list isnull
-
addSegment
Add a track segment to the track.- Parameters:
segment- the track segment added to the track- Returns:
thisBuilderfor method chaining- Throws:
NullPointerException- if the given argument isnull
-
addSegment
Add a track segment to the track, via the given builder.final Track track = Track.builder() .name("Track 1") .description("Mountain bike tour.") .addSegment(segment -> segment .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)))) .addSegment(segment -> segment .addPoint(p -> p.lat(46.2081743).lon(16.3738189).ele(160)) .addPoint(p -> p.lat(47.2081743).lon(16.3738189).ele(161)) .addPoint(p -> p.lat(49.2081743).lon(16.3738189).ele(162)))) .build();- Parameters:
segment- the track segment- Returns:
thisBuilderfor method chaining- Throws:
NullPointerException- if the given argument isnull
-
segments
Return the current track segments. The returned segment list is mutable.- Returns:
- the current track segments
- Since:
- 1.1
-
filter
Description copied from interface:FilterReturn a filter consisting of the elements of this filter that matches the given predicate.- Specified by:
filterin interfaceFilter<TrackSegment,Track> - 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<TrackSegment,Track> - 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<TrackSegment,Track> - 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 Track.Builder listMap(Function<? super List<TrackSegment>, ? extends List<TrackSegment>> mapper) Description copied from interface:FilterReturn a filter with the results of the applying given mapper function.- Specified by:
listMapin interfaceFilter<TrackSegment,Track> - Parameters:
mapper- a non-interfering, stateless function to apply to the existing elements- Returns:
- a new filter
-
build
Create a new GPX track from the current builder state.- Specified by:
buildin interfaceFilter<TrackSegment,Track> - Returns:
- a new GPX track from the current builder state
-