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

41 lines
1.1 KiB
Java

// "Fix all ''Optional' can be replaced with sequence of 'if' statements' problems in file" "true"
import java.util.*;
class Test {
String checkForNullable(String in) {
if (in == null) throw new NullPointerException();
String strOrNull = getStrOrNull(in);
if (strOrNull == null) throw new NoSuchElementException("No value present");
return strOrNull;
}
String checkIsRemovedForNotNull(String in) {
if (in == null) throw new NullPointerException();
String s = id(in);
if (s.length() <= 2) throw new NoSuchElementException("No value present");
return s;
}
String twoMapsProduceTwoVariables(String in, boolean b) {
if (in == null) throw new NullPointerException();
String s = id(in);
String strIfTrue = getStrIfTrue(s, b);
if (strIfTrue == null || strIfTrue.length <= 2) throw new NoSuchElementException("No value present");
return strIfTrue;
}
private String id(String s) {
return s;
}
private String getStrOrNull(String s) {
return s.length() > 2 ? s : null;
}
private String getStrIfTrue(String s, boolean b) {
return b ? s : null;
}
}