Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/optionalToIf/afterOr.java
Andrey.Cherkasov 0d10ba565e [java] Fix test data files after inspection description updating
GitOrigin-RevId: faa9f564b7a37e4c1165c24f904994b951adfccd
2021-03-18 10:49:54 +00:00

36 lines
799 B
Java

// "Fix all ''Optional' can be replaced with sequence of 'if' statements' problems in file" "true"
import java.util.*;
class Test {
String reusesVariable(String in) {
String s1 = null;
if (in == null) throw new NullPointerException();
String s = toName(in);
if (s != null) s1 = s;
if (s1 == null) {
String value = toDefaultName();
s1 = value;
}
return s1;
}
String removesRedundantAssignment(String in) {
String s1 = null;
String s = null;
if (in == null) throw new NullPointerException();
s = in;
return s;
}
private String toName(String str) {
if (str.startsWith("name")) return str.substring(4);
return null;
}
private String toDefaultName() {
return "defaultName";
}
}