Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/optionalToIf/afterOf.java
T
Artemiy Sartakov 6f1efb8fc0 OptionalToIfInspection: added inspection to desugar optional chain to sequence of if statements (IDEA-212269)
GitOrigin-RevId: c83b70e05544529b3dfffe24bc87997910edcb56
2019-08-07 17:02:43 +03:00

29 lines
766 B
Java

// "Fix all 'Optional can be replaced with sequence of if statements' problems in file" "true"
class Test {
void exceptionIsThrownOnNullValue(String in) {
if (in == null) throw new NullPointerException();
String out = in;
}
void exceptionIsTheSameWithOrElseThrow(String in) {
if (in == null) throw new NullPointerException();
Integer len = getLen(in);
if (len == null) throw new IllegalArgumentException("value is null");
Integer out = len;
}
void redundantCheckIsRemoved() {
String in = "not null value";
String out = in;
}
private Integer getLen(String s) {
return s.startsWith("abc") ? null : s;
}
private Integer filterLen(String s) {
return s.length() > 42 ? s.length() : null;
}
}