mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-16 00:14:33 +07:00
OptionalToIfInspection: preserve comments
GitOrigin-RevId: 7e97d9997d6f0eaca40e1e9cd720dc27e7ca687a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f58531c341
commit
7e0b374d13
+33
@@ -0,0 +1,33 @@
|
||||
// "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;
|
||||
/*1*/
|
||||
/*2*/
|
||||
/*3*/
|
||||
/*4*/
|
||||
LicenseManager result = null;
|
||||
if (instance != null) result = instance;
|
||||
if (result == null) result = setInstance(new IdeaLicenseManager(/*3*/));
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// "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*/;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user