Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/optionalToIf/beforePreserveComments.java
Artemiy Sartakov 7e0b374d13 OptionalToIfInspection: preserve comments
GitOrigin-RevId: 7e97d9997d6f0eaca40e1e9cd720dc27e7ca687a
2019-11-12 10:34:02 +00:00

26 lines
674 B
Java

// "Fix all 'Optional can be replaced with sequence of if statements' problems in file" "true"
import java.util.*;
class Test {
private LicenseManager ourInstance = null;
LicenseManager setInstance(LicenseManager instance) {
LicenseManager old = this.ourInstance;
this.ourInstance = instance;
return old;
}
private static interface LicenseManager {
}
private static class IdeaLicenseManager implements LicenseManager {
}
public LicenseManager getInstance() {
final LicenseManager instance = ourInstance;
return/*1*/ Optional.ofNul<caret>lable(instance/*2*/).orElseGet(() -> setInstance(new IdeaLicenseManager(/*3*/))) /*4*/;
}
}