mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-04 21:51:22 +07:00
21 lines
581 B
Java
21 lines
581 B
Java
// "Replace Optional.isPresent() condition with functional style expression" "true-preview"
|
|
import java.util.Optional;
|
|
|
|
class Trip implements Comparable<Trip> {
|
|
Optional<Integer> originId;
|
|
|
|
public Trip(Optional<Integer> originId) {
|
|
this.originId = originId;
|
|
}
|
|
|
|
public Optional<Integer> getOriginId() {
|
|
return originId;
|
|
}
|
|
|
|
@Override
|
|
public int compareTo(Trip o) {
|
|
return this.originId.isPresent() ?
|
|
(o.originId.is<caret>Present() ? Integer.compare(this.originId.get(), o.originId.get()) : -1) :
|
|
(o.originId.isPresent() ? 1 : 0);
|
|
}
|
|
} |