mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-30 10:20:15 +07:00
IDEA-181743 IntelliJ suggests bad refactoring for compareTo with Optionals
Reference expressions are compared instead of variables now
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
// "Replace Optional.isPresent() condition with functional style expression" "true"
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user