java.lang.Object
io.jenetics.jpx.GPX.Builder
- Enclosing class:
- GPX
Builder class for creating immutable
GPX objects.
Creating a GPX object with one track-segment and 3 track-points:
final GPX gpx = GPX.builder()
.addTrack(track -> track
.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))))
.build();-
Method Summary
Modifier and TypeMethodDescriptionAdd a route theGPXobject.addRoute(Consumer<? super Route.Builder> route) Add a route theGPXobject.Add a track theGPXobject.addTrack(Consumer<? super Track.Builder> track) Add a track theGPXobject.addWayPoint(WayPoint wayPoint) Add one way-point to theGPXobject.addWayPoint(Consumer<? super WayPoint.Builder> wayPoint) Add a way-point to theGPXobject using aWayPoint.Builder.build()Create an immutableGPXobject from the current builder state.creator()Return the current creator value.Set the GPX creator.Return the current extensionsextensions(Document extensions) Sets the extensions object, which may benull.metadata()Return the current metadata value.Set the GPX metadata.metadata(Consumer<? super Metadata.Builder> metadata) Allows setting partial metadata without messing up with theMetadata.Builderclass.Return a newRoutefilter.routes()Return the current routes.Sets the routes of theGPXobject.Return a newTrackfilter.tracks()Return the current tracks.Sets the tracks of theGPXobject.version()Return the current version value.version(GPX.Version version) Set the GPX version.Return a newWayPointfilter.Return the current way-points.Sets the way-points of theGPXobject.
-
Method Details
-
creator
Set the GPX creator.- Parameters:
creator- the GPX creator- Returns:
thisBuilderfor method chaining- Throws:
NullPointerException- if the given argument isnull
-
creator
Return the current creator value.- Returns:
- the current creator value
- Since:
- 1.1
-
version
Set the GPX version.- Parameters:
version- the GPX version- Returns:
thisBuilderfor method chaining- Throws:
NullPointerException- if the given argument isnull- Since:
- 1.3
-
version
Return the current version value.- Returns:
- the current version value
- Since:
- 1.1
-
metadata
Set the GPX metadata.- Parameters:
metadata- the GPX metadata- Returns:
thisBuilderfor method chaining
-
metadata
Allows setting partial metadata without messing up with theMetadata.Builderclass.final GPX gpx = GPX.builder() .metadata(md -> md.author("Franz Wilhelmstötter")) .addTrack(...) .build();- Parameters:
metadata- the metadata consumer- Returns:
thisBuilderfor method chaining- Throws:
NullPointerException- if the given argument isnull
-
metadata
Return the current metadata value.- Returns:
- the current metadata value
- Since:
- 1.1
-
wayPoints
Sets the way-points of theGPXobject. The list of way-points may benull.- Parameters:
wayPoints- theGPXway-points- Returns:
thisBuilderfor method chaining- Throws:
NullPointerException- if one of the way-points in the list isnull
-
addWayPoint
Add one way-point to theGPXobject.- Parameters:
wayPoint- the way-point to add- Returns:
thisBuilderfor method chaining- Throws:
NullPointerException- if the givenwayPointisnull
-
addWayPoint
Add a way-point to theGPXobject using aWayPoint.Builder.final GPX gpx = GPX.builder() .addWayPoint(wp -> wp.lat(23.6).lon(13.5).ele(50)) .build();- Parameters:
wayPoint- the way-point to add, configured by the way-point builder- Returns:
thisBuilderfor method chaining- Throws:
NullPointerException- if the given argument isnull
-
wayPoints
Return the current way-points. The returned list is mutable.- Returns:
- the current, mutable way-point list
- Since:
- 1.1
-
routes
Sets the routes of theGPXobject. The list of routes may benull.- Parameters:
routes- theGPXroutes- Returns:
thisBuilderfor method chaining- Throws:
NullPointerException- if one of the routes isnull
-
addRoute
Add a route theGPXobject.- Parameters:
route- the route to add- Returns:
thisBuilderfor method chaining- Throws:
NullPointerException- if the givenrouteisnull
-
addRoute
Add a route theGPXobject.final GPX gpx = GPX.builder() .addRoute(route -> route .addPoint(p -> p.lat(48.2081743).lon(16.3738189).ele(160)) .addPoint(p -> p.lat(48.2081743).lon(16.3738189).ele(161))) .build();- Parameters:
route- the route to add, configured by the route builder- Returns:
thisBuilderfor method chaining- Throws:
NullPointerException- if the given argument isnull
-
routes
Return the current routes. The returned list is mutable.- Returns:
- the current, mutable route list
- Since:
- 1.1
-
tracks
Sets the tracks of theGPXobject. The list of tracks may benull.- Parameters:
tracks- theGPXtracks- Returns:
thisBuilderfor method chaining- Throws:
NullPointerException- if one of the tracks isnull
-
addTrack
Add a track theGPXobject.- Parameters:
track- the track to add- Returns:
thisBuilderfor method chaining- Throws:
NullPointerException- if the giventrackisnull
-
addTrack
Add a track theGPXobject.final GPX gpx = GPX.builder() .addTrack(track -> track .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)))) .build();- Parameters:
track- the track to add, configured by the track builder- Returns:
thisBuilderfor method chaining- Throws:
NullPointerException- if the given argument isnull
-
tracks
Return the current tracks. The returned list is mutable.- Returns:
- the current, mutable track 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 extensions 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
-
build
Create an immutableGPXobject from the current builder state.- Returns:
- an immutable
GPXobject from the current builder state
-
wayPointFilter
Return a newWayPointfilter.final GPX filtered = gpx.toBuilder() .wayPointFilter() .filter(wp -> wp.getTime().isPresent()) .build()) .build();- Returns:
- a new
WayPointfilter - Since:
- 1.1
-
routeFilter
Return a newRoutefilter.final GPX filtered = gpx.toBuilder() .routeFilter() .filter(Route::nonEmpty) .build()) .build();- Returns:
- a new
Routefilter - Since:
- 1.1
-
trackFilter
Return a newTrackfilter.final GPX merged = gpx.toBuilder() .trackFilter() .map(track -> track.toBuilder() .listMap(Filters::mergeSegments) .filter(TrackSegment::nonEmpty) .build()) .build() .build();- Returns:
- a new
Trackfilter - Since:
- 1.1
-