public static final class GPX.Builder extends Object
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();
Modifier and Type | Method and Description |
---|---|
GPX.Builder |
addRoute(Consumer<Route.Builder> route)
Add a route the
GPX object. |
GPX.Builder |
addRoute(Route route)
Add a route the
GPX object. |
GPX.Builder |
addTrack(Consumer<Track.Builder> track)
Add a track the
GPX object. |
GPX.Builder |
addTrack(Track track)
Add a track the
GPX object. |
GPX.Builder |
addWayPoint(Consumer<WayPoint.Builder> wayPoint)
Add a way-point to the
GPX object using a
WayPoint.Builder . |
GPX.Builder |
addWayPoint(WayPoint wayPoint)
Add one way-point to the
GPX object. |
GPX |
build()
Create an immutable
GPX object from the current builder state. |
String |
creator()
Return the current creator value.
|
GPX.Builder |
creator(String creator)
Set the GPX creator.
|
Optional<Metadata> |
metadata()
Return the current metadata value.
|
GPX.Builder |
metadata(Consumer<Metadata.Builder> metadata)
Allows to set partial metadata without messing up with the
Metadata.Builder class. |
GPX.Builder |
metadata(Metadata metadata)
Set the GPX metadata.
|
Filter<Route,GPX.Builder> |
routeFilter()
Return a new
Route filter. |
List<Route> |
routes()
Return the current routes.
|
GPX.Builder |
routes(List<Route> routes)
Sets the routes of the
GPX object. |
Filter<Track,GPX.Builder> |
trackFilter()
Return a new
Track filter. |
List<Track> |
tracks()
Return the current tracks.
|
GPX.Builder |
tracks(List<Track> tracks)
Sets the tracks of the
GPX object. |
String |
version()
Return the current version value.
|
GPX.Builder |
version(GPX.Version version)
Set the GPX version.
|
Filter<WayPoint,GPX.Builder> |
wayPointFilter()
Return a new
WayPoint filter. |
List<WayPoint> |
wayPoints()
Return the current way-points.
|
GPX.Builder |
wayPoints(List<WayPoint> wayPoints)
Sets the way-points of the
GPX object. |
public GPX.Builder creator(String creator)
creator
- the GPX creatorthis
Builder
for method chainingNullPointerException
- if the given argument is null
public String creator()
public GPX.Builder version(GPX.Version version)
version
- the GPX versionthis
Builder
for method chainingNullPointerException
- if the given argument is null
public String version()
public GPX.Builder metadata(Metadata metadata)
metadata
- the GPX metadatathis
Builder
for method chainingpublic GPX.Builder metadata(Consumer<Metadata.Builder> metadata)
Metadata.Builder
class.
final GPX gpx = GPX.builder()
.metadata(md -> md.author("Franz Wilhelmstötter"))
.addTrack(...)
.build();
metadata
- the metadata consumerthis
Builder
for method chainingNullPointerException
- if the given argument is null
public Optional<Metadata> metadata()
public GPX.Builder wayPoints(List<WayPoint> wayPoints)
GPX
object. The list of way-points
may be null
.wayPoints
- the GPX
way-pointsthis
Builder
for method chainingNullPointerException
- if one of the way-points in the list is
null
public GPX.Builder addWayPoint(WayPoint wayPoint)
GPX
object.wayPoint
- the way-point to addthis
Builder
for method chainingNullPointerException
- if the given wayPoint
is
null
public GPX.Builder addWayPoint(Consumer<WayPoint.Builder> wayPoint)
GPX
object using a
WayPoint.Builder
.
final GPX gpx = GPX.builder()
.addWayPoint(wp -> wp.lat(23.6).lon(13.5).ele(50))
.build();
wayPoint
- the way-point to add, configured by the way-point
builderthis
Builder
for method chainingNullPointerException
- if the given argument is null
public List<WayPoint> wayPoints()
public GPX.Builder routes(List<Route> routes)
GPX
object. The list of routes may be
null
.routes
- the GPX
routesthis
Builder
for method chainingNullPointerException
- if one of the routes is null
public GPX.Builder addRoute(Route route)
GPX
object.route
- the route to addthis
Builder
for method chainingNullPointerException
- if the given route
is null
public GPX.Builder addRoute(Consumer<Route.Builder> route)
GPX
object.
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();
route
- the route to add, configured by the route builderthis
Builder
for method chainingNullPointerException
- if the given argument is null
public List<Route> routes()
public GPX.Builder tracks(List<Track> tracks)
GPX
object. The list of tracks may be
null
.tracks
- the GPX
tracksthis
Builder
for method chainingNullPointerException
- if one of the tracks is null
public GPX.Builder addTrack(Track track)
GPX
object.track
- the track to addthis
Builder
for method chainingNullPointerException
- if the given track
is null
public GPX.Builder addTrack(Consumer<Track.Builder> track)
GPX
object.
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();
track
- the track to add, configured by the track builderthis
Builder
for method chainingNullPointerException
- if the given argument is null
public List<Track> tracks()
public GPX build()
GPX
object from the current builder state.GPX
object from the current builder statepublic Filter<WayPoint,GPX.Builder> wayPointFilter()
WayPoint
filter.
final GPX filtered = gpx.toBuilder()
.wayPointFilter()
.filter(wp -> wp.getTime().isPresent())
.build())
.build();
WayPoint
filterpublic Filter<Route,GPX.Builder> routeFilter()
Route
filter.
final GPX filtered = gpx.toBuilder()
.routeFilter()
.filter(Route::nonEmpty)
.build())
.build();
Route
filterpublic Filter<Track,GPX.Builder> trackFilter()
Track
filter.
final GPX merged = gpx.toBuilder()
.trackFilter()
.map(track -> track.toBuilder()
.listMap(Filters::mergeSegments)
.filter(TrackSegment::nonEmpty)
.build())
.build()
.build();
Track
filter© 2016-2018 Franz Wilhelmstötter (2018-04-01 17:06)