mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-07 22:09:38 +07:00
IDEA-168201 Intention to extract a set from "foo".equals(xyz) || "bar".equals(xyz)
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
// "Extract Set from comparison chain" "true"
|
||||
public class Test {
|
||||
private static final Set<String> NAMES = new HashSet<>(Arrays.asList("foo", "bar", "baz"));
|
||||
|
||||
void testOr(String name) {
|
||||
if(name == null || NAMES.contains(name)) {
|
||||
System.out.println("foobarbaz");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
// "Extract Set from comparison chain" "true"
|
||||
public class Test {
|
||||
private static final Set<String> NAMES = new HashSet<>(Arrays.asList("foo", "bar", "baz"));
|
||||
|
||||
interface Person {
|
||||
String getName();
|
||||
}
|
||||
|
||||
void testOr(Person person) {
|
||||
if(NAMES.contains(person.getName()) || person.getName() == null) {
|
||||
System.out.println("foobarbaz");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
// "Extract Set from comparison chain" "true"
|
||||
public class Test {
|
||||
public static final String BAR = "bar";
|
||||
private static final Set<String> PROPERTIES = new HashSet<>(Arrays.asList("foo", BAR, "baz"));
|
||||
|
||||
void testOr(int i, String property) {
|
||||
int PROPERTIES;
|
||||
|
||||
if(i > 0 && Test.PROPERTIES.contains(property)) {
|
||||
System.out.println("foobarbaz");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
// "Extract Set from comparison chain" "true"
|
||||
public class Test {
|
||||
private static final Set<String> S = new HashSet<>(Arrays.asList("foo", "bar", "baz"));
|
||||
|
||||
void testOr(String s) {
|
||||
if(S.contains(s)) {
|
||||
System.out.println("foobarbaz");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Extract Set from comparison chain" "true"
|
||||
public class Test {
|
||||
void testOr(String name) {
|
||||
if(name == null || <caret>"foo".equals(name) || "bar".equals(name) || "baz".equals(name)) {
|
||||
System.out.println("foobarbaz");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Extract Set from comparison chain" "false"
|
||||
public class Test {
|
||||
void testOr(String s) {
|
||||
if(s == nul<caret>l || "foo".equals(s) || "bar".equals(s) || "baz".equals(s)) {
|
||||
System.out.println("foobarbaz");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// "Extract Set from comparison chain" "true"
|
||||
public class Test {
|
||||
interface Person {
|
||||
String getName();
|
||||
}
|
||||
|
||||
void testOr(Person person) {
|
||||
if("foo".equals(person.getName()) || "bar".equals(person.getName()) || "baz".equals(person.getName()<caret>) || person.getName() == null) {
|
||||
System.out.println("foobarbaz");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Extract Set from comparison chain" "false"
|
||||
public class Test {
|
||||
void testOr(String s) {
|
||||
if("foo".equals(s) || "bar".equals(s) || "baz".equals(s) || s<caret> == null) {
|
||||
System.out.println("foobarbaz");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// "Extract Set from comparison chain" "true"
|
||||
public class Test {
|
||||
public static final String BAR = "bar";
|
||||
|
||||
void testOr(int i, String property) {
|
||||
int PROPERTIES;
|
||||
|
||||
if(i > 0 && ("foo"<caret>.equals(property) || BAR.equals(property) || "baz".equals(property))) {
|
||||
System.out.println("foobarbaz");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Extract Set from comparison chain" "true"
|
||||
public class Test {
|
||||
void testOr(String s) {
|
||||
if("foo"<caret>.equals(s) || "bar".equals(s) || "baz".equals(s)) {
|
||||
System.out.println("foobarbaz");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user