mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-05 04:40:28 +07:00
56 lines
1.2 KiB
Java
56 lines
1.2 KiB
Java
// "Fix all 'Optional can be replaced with sequence of if statements' problems in file" "true"
|
|
|
|
import java.util.*;
|
|
|
|
class Test {
|
|
|
|
private void reusesVariable(String in) {
|
|
if (in == null) throw new NullPointerException();
|
|
String id = id(in);
|
|
if (id == null) throw new NoSuchElementException("No value present");
|
|
Object out = id;
|
|
}
|
|
|
|
private void checkIsRemoved(String in) {
|
|
if (in == null) throw new NullPointerException();
|
|
String out = in;
|
|
}
|
|
|
|
void simple(String in) {
|
|
String out = "bar";
|
|
if (in != null) out = in;
|
|
}
|
|
|
|
void simpleWithMap(String in) {
|
|
String out = "bar";
|
|
if (in != null) {
|
|
String id = id(in);
|
|
if (id != null) out = id;
|
|
}
|
|
}
|
|
|
|
void nested(String in) {
|
|
String out = "bar";
|
|
if (in != null) out = in;
|
|
}
|
|
|
|
void outer(String in, String p) {
|
|
String out = "bar";
|
|
if (in != null) {
|
|
String value = in + in + p;
|
|
out = value;
|
|
}
|
|
}
|
|
|
|
void nullableOuter(String in, String p) {
|
|
String out = "bar";
|
|
if (in != null) {
|
|
if (p == null) throw new NullPointerException();
|
|
out = p;
|
|
}
|
|
}
|
|
|
|
<T> T id(T t) {
|
|
return t;
|
|
}
|
|
} |