mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-26 19:06:24 +07:00
Java9CollectionFactoryInspection: add type argument if necessary
This commit is contained in:
+1
-1
@@ -5,5 +5,5 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Test {
|
||||
public static final List<Number> EVEN = List.of(2, 4, 6, 8, 10);
|
||||
public static final List<Number> EVEN = List.<Number>of(2, 4, 6, 8, 10);
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,5 +4,5 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Test {
|
||||
public static final List<Number> EVEN = List.of(0, 2, 4, 6, 8);
|
||||
public static final List<Number> EVEN = List.<Number>of(0, 2, 4, 6, 8);
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import java.util.*;
|
||||
public class Test {
|
||||
public void testList() {
|
||||
List<Integer> list;
|
||||
list = List.of(1, 2);
|
||||
list = List.<Integer>of(1, 2);
|
||||
System.out.println(list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,5 +4,5 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Test {
|
||||
public static final List<Number> EVEN = List.of(2, 4, 6, 8, 10, 2);
|
||||
public static final List<Number> EVEN = List.<Number>of(2, 4, 6, 8, 10, 2);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Replace with 'List.of' call" "true"
|
||||
import java.util.*;
|
||||
|
||||
public class Test {
|
||||
public void test() {
|
||||
List<String[]> list = List.<String[]>of(new String[]{"aaa"});
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,6 @@ import java.util.*;
|
||||
public class Test {
|
||||
public void test() {
|
||||
Map<String, String> myMap;
|
||||
myMap = Map.of("a", "1", "b", "1", "c", "1", "d", "1", "e", "1", "f", "1", "g", "1", "h", "1", "i", "1", "j", "1");
|
||||
myMap = Map.<String, String>of("a", "1", "b", "1", "c", "1", "d", "1", "e", "1", "f", "1", "g", "1", "h", "1", "i", "1", "j", "1");
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,6 @@ import java.util.*;
|
||||
public class Test {
|
||||
public void test() {
|
||||
Map<String, String> myMap;
|
||||
myMap = Map.of("a", "b", "c", "b");
|
||||
myMap = Map.<String, String>of("a", "b", "c", "b");
|
||||
}
|
||||
}
|
||||
@@ -5,5 +5,5 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class Test {
|
||||
public static final Set<String> MY_SET = Set.of("a", "b", "c", Math.random() > 0.5 ? "d" : Math.random() > 0.5 ? "e" : "d");
|
||||
public static final Set<String> MY_SET = Set.<String>of("a", "b", "c", Math.random() > 0.5 ? "d" : Math.random() > 0.5 ? "e" : "d");
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,5 +4,5 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class Test {
|
||||
public static final Set<String> MY_SET = Set.of("a", "b", "c".toUpperCase());
|
||||
public static final Set<String> MY_SET = Set.<String>of("a", "b", "c".toUpperCase());
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,6 +6,6 @@ public class Test {
|
||||
|
||||
static {
|
||||
Set<String> set;
|
||||
MY_SET = Set.of("foo", "bar", "xyz");
|
||||
MY_SET = Set.<String>of("foo", "bar", "xyz");
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@ import java.util.*;
|
||||
public class Test {
|
||||
public void test2() {
|
||||
Set<String> set;
|
||||
set = Set.of("foo", "bar", "xyz");
|
||||
set = Set.<String>of("foo", "bar", "xyz");
|
||||
System.out.println(set);
|
||||
}
|
||||
}
|
||||
@@ -5,5 +5,5 @@ import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class Test {
|
||||
public static final List<Class<?>> MY_LIST = List.of(String.class, int.class, Object.class);
|
||||
public static final List<Class<?>> MY_LIST = List.<Class<?>>of(String.class, int.class, Object.class);
|
||||
}
|
||||
|
||||
@@ -5,5 +5,5 @@ import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class Test {
|
||||
public static final Set<Class<?>> MY_SET = Set.of(String.class, int.class, Object.class);
|
||||
public static final Set<Class<?>> MY_SET = Set.<Class<?>>of(String.class, int.class, Object.class);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Replace with 'List.of' call" "true"
|
||||
import java.util.*;
|
||||
|
||||
public class Test {
|
||||
public void test() {
|
||||
List<String[]> list = Collections.unmodif<caret>iableList(Arrays.<String[]>asList(new String[] {"aaa"}));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user