Skip to content

Commit

Permalink
replace Objects.requireNonNullElseGet with tenary operator
Browse files Browse the repository at this point in the history
  • Loading branch information
pstorch committed Jul 16, 2024
1 parent 6c871b6 commit 9bff3eb
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import java.time.Duration;
import java.time.ZoneOffset;
import java.util.Objects;

import de.dennisguse.opentracks.R;
import de.dennisguse.opentracks.data.ContentProviderUtils;
Expand Down Expand Up @@ -140,7 +139,7 @@ Pair<Track, Pair<TrackPoint, SensorDataSet>> getDataForUI() {
}

public Marker.Id insertMarker(String name, String category, String description, String photoUrl, Track.Id trackId, TrackPoint trackPoint) {
Track.Id markerTrackId = Objects.requireNonNullElseGet(trackId, () -> this.trackId);
Track.Id markerTrackId = trackId != null ? trackId : this.trackId;
if (name == null) {
Integer nextMarkerNumber = contentProviderUtils.getNextMarkerNumber(markerTrackId);
if (nextMarkerNumber == null) {
Expand All @@ -149,11 +148,11 @@ public Marker.Id insertMarker(String name, String category, String description,
name = context.getString(R.string.marker_name_format, nextMarkerNumber + 1);
}

if (lastStoredTrackPointWithLocation == null && trackPoint == null) {
TrackPoint markerTrackPoint = trackPoint != null ? trackPoint : lastStoredTrackPointWithLocation;
if (markerTrackPoint == null) {
Log.i(TAG, "Could not create a marker as trackPoint is unknown.");
return null;
}
TrackPoint markerTrackPoint = Objects.requireNonNullElseGet(trackPoint, () -> lastStoredTrackPointWithLocation);

category = category != null ? category : "";
description = description != null ? description : "";
Expand Down

0 comments on commit 9bff3eb

Please sign in to comment.