// "Replace Optional presence condition with functional style expression" "true-preview" import java.util.Optional; class Trip implements Comparable { Optional originId; public Trip(Optional originId) { this.originId = originId; } public Optional getOriginId() { return originId; } @Override public int compareTo(Trip o) { return this.originId.isPresent() ? (o.originId.isPresent() ? Integer.compare(this.originId.get(), o.originId.get()) : -1) : (o.originId.isPresent() ? 1 : 0); } }