@Test public void nonEmptyFilter() throws IOException { final GPX gpx = GPX.read(new ByteArrayInputStream(( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<gpx version=\"1.1\" creator=\"JPX - https: "xmlns=\"http: " <metadata></metadata>\n" + " <trk><trkseg></trkseg></trk>\n" + " <trk>\n" + " <trkseg></trkseg>\n" + " <trkseg>\n" + " <trkpt lat=\"21.0\" lon=\"23.0\">\n" + " <ele>12.0</ele>\n" + " </trkpt>\n" + " </trkseg>\n" + " </trk>\n" + " <trk></trk>\n" + "</gpx>").getBytes())); final GPX nonEmpty = Filters.nonEmptyGPX(gpx); final GPX expected = GPX.builder() .addTrack(track -> track .addSegment(segment -> segment .addPoint(wp -> wp.lat(21.0).lon(23.0).ele(12.0)))) .build(); Assert.assertEquals(nonEmpty, expected); }
public static GPX nonEmptyGPX(final GPX gpx) { return gpx.toBuilder() .routeFilter() .listMap(Filters::nonEmptyRoutes) .build() .trackFilter() .listMap(Filters::nonEmptyTracks) .build() .metadata(gpx.getMetadata() .filter(Metadata::nonEmpty) .orElse(null)) .build(); }
Filters { public static GPX nonEmptyGPX(final GPX gpx) { return gpx.toBuilder() .routeFilter() .listMap(Filters::nonEmptyRoutes) .build() .trackFilter() .listMap(Filters::nonEmptyTracks) .build() .metadata(gpx.getMetadata() .filter(Metadata::nonEmpty) .orElse(null)) .build(); } }
Filters { public static GPX nonEmptyGPX(final GPX gpx) { return gpx.toBuilder() .routeFilter() .listMap(Filters::nonEmptyRoutes) .build() .trackFilter() .listMap(Filters::nonEmptyTracks) .build() .metadata(gpx.getMetadata() .filter(Metadata::nonEmpty) .orElse(null)) .build(); } private  Filters(); }
Filters { public static GPX nonEmptyGPX(final GPX gpx) { return gpx.toBuilder() .routeFilter() .listMap(Filters::nonEmptyRoutes) .build() .trackFilter() .listMap(Filters::nonEmptyTracks) .build() .metadata(gpx.getMetadata() .filter(Metadata::nonEmpty) .orElse(null)) .build(); } private  Filters(); static List<TrackSegment> mergeSegments(
		final List<TrackSegment> segments
	); static List<Track> mergeTracks(final List<Track> tracks); static List<Track> fullyMergeTracks(final List<Track> tracks); static GPX nonEmptyGPX(final GPX gpx); static List<Route> nonEmptyRoutes(final List<Route> routes); static List<Track> nonEmptyTracks(final List<Track> tracks); static List<TrackSegment> nonEmptySegments(
		final List<TrackSegment> segments
	); }
Filters { public static GPX nonEmptyGPX(final GPX gpx) { return gpx.toBuilder() .routeFilter() .listMap(Filters::nonEmptyRoutes) .build() .trackFilter() .listMap(Filters::nonEmptyTracks) .build() .metadata(gpx.getMetadata() .filter(Metadata::nonEmpty) .orElse(null)) .build(); } private  Filters(); static List<TrackSegment> mergeSegments(
		final List<TrackSegment> segments
	); static List<Track> mergeTracks(final List<Track> tracks); static List<Track> fullyMergeTracks(final List<Track> tracks); static GPX nonEmptyGPX(final GPX gpx); static List<Route> nonEmptyRoutes(final List<Route> routes); static List<Track> nonEmptyTracks(final List<Track> tracks); static List<TrackSegment> nonEmptySegments(
		final List<TrackSegment> segments
	);  }