Explicit type parameters can be removed
This commit is contained in:
parent
487b1a7ec4
commit
f013141f60
|
@ -75,7 +75,7 @@ public class CharSet implements Serializable {
|
|||
* Subclasses can add more common patterns if desired
|
||||
* @since 2.0
|
||||
*/
|
||||
protected static final Map<String, CharSet> COMMON = Collections.synchronizedMap(new HashMap<String, CharSet>());
|
||||
protected static final Map<String, CharSet> COMMON = Collections.synchronizedMap(new HashMap<>());
|
||||
|
||||
static {
|
||||
COMMON.put(null, EMPTY);
|
||||
|
@ -88,7 +88,7 @@ public class CharSet implements Serializable {
|
|||
}
|
||||
|
||||
/** The set of CharRange objects. */
|
||||
private final Set<CharRange> set = Collections.synchronizedSet(new HashSet<CharRange>());
|
||||
private final Set<CharRange> set = Collections.synchronizedSet(new HashSet<>());
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
|
|
|
@ -1383,7 +1383,7 @@ public class ClassUtils {
|
|||
|
||||
@Override
|
||||
public Iterator<Class<?>> iterator() {
|
||||
final MutableObject<Class<?>> next = new MutableObject<Class<?>>(type);
|
||||
final MutableObject<Class<?>> next = new MutableObject<>(type);
|
||||
return new Iterator<Class<?>>() {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -903,7 +903,7 @@ public class MethodUtils {
|
|||
Validate.isTrue(cls != null, "The class must not be null");
|
||||
Validate.isTrue(annotationCls != null, "The annotation class must not be null");
|
||||
final List<Class<?>> classes = (searchSupers ? getAllSuperclassesAndInterfaces(cls)
|
||||
: new ArrayList<Class<?>>());
|
||||
: new ArrayList<>());
|
||||
classes.add(0, cls);
|
||||
final List<Method> annotatedMethods = new ArrayList<>();
|
||||
for (final Class<?> acls : classes) {
|
||||
|
|
|
@ -864,7 +864,7 @@ public class TypeUtils {
|
|||
getRawType(parameterizedOwnerType), subtypeVarAssigns);
|
||||
} else {
|
||||
// no owner, prep the type variable assignments map
|
||||
typeVarAssigns = subtypeVarAssigns == null ? new HashMap<TypeVariable<?>, Type>()
|
||||
typeVarAssigns = subtypeVarAssigns == null ? new HashMap<>()
|
||||
: new HashMap<>(subtypeVarAssigns);
|
||||
}
|
||||
|
||||
|
@ -918,7 +918,7 @@ public class TypeUtils {
|
|||
}
|
||||
|
||||
// create a copy of the incoming map, or an empty one if it's null
|
||||
final HashMap<TypeVariable<?>, Type> typeVarAssigns = subtypeVarAssigns == null ? new HashMap<TypeVariable<?>, Type>()
|
||||
final HashMap<TypeVariable<?>, Type> typeVarAssigns = subtypeVarAssigns == null ? new HashMap<>()
|
||||
: new HashMap<>(subtypeVarAssigns);
|
||||
|
||||
// has target class been reached?
|
||||
|
|
|
@ -207,13 +207,13 @@ public class ObjectUtilsTest {
|
|||
final List<Object> list0 = new ArrayList<>(Arrays.asList(new Object[0]));
|
||||
assertEquals(list0.hashCode(), ObjectUtils.hashCodeMulti());
|
||||
|
||||
final List<Object> list1 = new ArrayList<Object>(Arrays.asList("a"));
|
||||
final List<Object> list1 = new ArrayList<>(Arrays.asList("a"));
|
||||
assertEquals(list1.hashCode(), ObjectUtils.hashCodeMulti("a"));
|
||||
|
||||
final List<Object> list2 = new ArrayList<Object>(Arrays.asList("a", "b"));
|
||||
final List<Object> list2 = new ArrayList<>(Arrays.asList("a", "b"));
|
||||
assertEquals(list2.hashCode(), ObjectUtils.hashCodeMulti("a", "b"));
|
||||
|
||||
final List<Object> list3 = new ArrayList<Object>(Arrays.asList("a", "b", "c"));
|
||||
final List<Object> list3 = new ArrayList<>(Arrays.asList("a", "b", "c"));
|
||||
assertEquals(list3.hashCode(), ObjectUtils.hashCodeMulti("a", "b", "c"));
|
||||
}
|
||||
|
||||
|
|
|
@ -433,9 +433,9 @@ public class EqualsBuilderTest {
|
|||
|
||||
@Test
|
||||
public void testObjectRecursiveGenericInteger() {
|
||||
final TestRecursiveGenericObject<Integer> o1_a = new TestRecursiveGenericObject<Integer>(1);
|
||||
final TestRecursiveGenericObject<Integer> o1_b = new TestRecursiveGenericObject<Integer>(1);
|
||||
final TestRecursiveGenericObject<Integer> o2 = new TestRecursiveGenericObject<Integer>(2);
|
||||
final TestRecursiveGenericObject<Integer> o1_a = new TestRecursiveGenericObject<>(1);
|
||||
final TestRecursiveGenericObject<Integer> o1_b = new TestRecursiveGenericObject<>(1);
|
||||
final TestRecursiveGenericObject<Integer> o2 = new TestRecursiveGenericObject<>(2);
|
||||
|
||||
assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1_a, o1_b).isEquals());
|
||||
assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1_b, o1_a).isEquals());
|
||||
|
@ -447,9 +447,9 @@ public class EqualsBuilderTest {
|
|||
public void testObjectRecursiveGenericString() {
|
||||
// Note: Do not use literals, because string literals are always mapped by same object (internal() of String))!
|
||||
String s1_a = String.valueOf(1);
|
||||
final TestRecursiveGenericObject<String> o1_a = new TestRecursiveGenericObject<String>(s1_a);
|
||||
final TestRecursiveGenericObject<String> o1_b = new TestRecursiveGenericObject<String>(String.valueOf(1));
|
||||
final TestRecursiveGenericObject<String> o2 = new TestRecursiveGenericObject<String>(String.valueOf(2));
|
||||
final TestRecursiveGenericObject<String> o1_a = new TestRecursiveGenericObject<>(s1_a);
|
||||
final TestRecursiveGenericObject<String> o1_b = new TestRecursiveGenericObject<>(String.valueOf(1));
|
||||
final TestRecursiveGenericObject<String> o2 = new TestRecursiveGenericObject<>(String.valueOf(2));
|
||||
|
||||
// To trigger bug reported in LANG-1356, call hashCode only on string in instance o1_a
|
||||
s1_a.hashCode();
|
||||
|
|
|
@ -65,19 +65,19 @@ public class ReflectionToStringBuilderConcurrencyTest {
|
|||
@Test
|
||||
@Ignore
|
||||
public void testLinkedList() throws InterruptedException, ExecutionException {
|
||||
this.testConcurrency(new CollectionHolder<List<Integer>>(new LinkedList<Integer>()));
|
||||
this.testConcurrency(new CollectionHolder<>(new LinkedList<>()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testArrayList() throws InterruptedException, ExecutionException {
|
||||
this.testConcurrency(new CollectionHolder<List<Integer>>(new ArrayList<Integer>()));
|
||||
this.testConcurrency(new CollectionHolder<>(new ArrayList<>()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testCopyOnWriteArrayList() throws InterruptedException, ExecutionException {
|
||||
this.testConcurrency(new CollectionHolder<List<Integer>>(new CopyOnWriteArrayList<Integer>()));
|
||||
this.testConcurrency(new CollectionHolder<>(new CopyOnWriteArrayList<>()));
|
||||
}
|
||||
|
||||
private void testConcurrency(final CollectionHolder<List<Integer>> holder) throws InterruptedException,
|
||||
|
|
|
@ -104,7 +104,7 @@ public class ReflectionToStringBuilderExcludeTest {
|
|||
|
||||
@Test
|
||||
public void test_toStringExcludeEmptyCollection() {
|
||||
final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new ArrayList<String>());
|
||||
final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new ArrayList<>());
|
||||
this.validateSecretFieldPresent(toString);
|
||||
}
|
||||
|
||||
|
|
|
@ -68,17 +68,17 @@ public class ToStringStyleConcurrencyTest {
|
|||
|
||||
@Test
|
||||
public void testLinkedList() throws InterruptedException, ExecutionException {
|
||||
this.testConcurrency(new CollectionHolder<List<Integer>>(new LinkedList<Integer>()));
|
||||
this.testConcurrency(new CollectionHolder<>(new LinkedList<>()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testArrayList() throws InterruptedException, ExecutionException {
|
||||
this.testConcurrency(new CollectionHolder<List<Integer>>(new ArrayList<Integer>()));
|
||||
this.testConcurrency(new CollectionHolder<>(new ArrayList<>()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCopyOnWriteArrayList() throws InterruptedException, ExecutionException {
|
||||
this.testConcurrency(new CollectionHolder<List<Integer>>(new CopyOnWriteArrayList<Integer>()));
|
||||
this.testConcurrency(new CollectionHolder<>(new CopyOnWriteArrayList<>()));
|
||||
}
|
||||
|
||||
private void testConcurrency(final CollectionHolder<List<Integer>> holder) throws InterruptedException,
|
||||
|
|
|
@ -580,7 +580,7 @@ public class ConcurrentUtilsTest {
|
|||
EasyMock.replay(init);
|
||||
try {
|
||||
ConcurrentUtils.createIfAbsentUnchecked(
|
||||
new ConcurrentHashMap<String, Integer>(), "test", init);
|
||||
new ConcurrentHashMap<>(), "test", init);
|
||||
fail("Exception not thrown!");
|
||||
} catch (final ConcurrentRuntimeException crex) {
|
||||
assertEquals("Wrong cause", ex, crex.getCause());
|
||||
|
|
|
@ -275,19 +275,19 @@ public class MethodUtilsTest {
|
|||
// not only is the correct overloaded variant invoked, but that the varags arguments
|
||||
// are also delivered correctly to the method.
|
||||
public ImmutablePair<String, Object[]> varOverloadEcho(final String... args) {
|
||||
return new ImmutablePair<String, Object[]>("String...", args);
|
||||
return new ImmutablePair<>("String...", args);
|
||||
}
|
||||
|
||||
public ImmutablePair<String, Object[]> varOverloadEcho(final Number... args) {
|
||||
return new ImmutablePair<String, Object[]>("Number...", args);
|
||||
return new ImmutablePair<>("Number...", args);
|
||||
}
|
||||
|
||||
public static ImmutablePair<String, Object[]> varOverloadEchoStatic(final String... args) {
|
||||
return new ImmutablePair<String, Object[]>("String...", args);
|
||||
return new ImmutablePair<>("String...", args);
|
||||
}
|
||||
|
||||
public static ImmutablePair<String, Object[]> varOverloadEchoStatic(final Number... args) {
|
||||
return new ImmutablePair<String, Object[]>("Number...", args);
|
||||
return new ImmutablePair<>("Number...", args);
|
||||
}
|
||||
|
||||
static void verify(final ImmutablePair<String, Object[]> a, final ImmutablePair<String, Object[]> b) {
|
||||
|
@ -441,13 +441,13 @@ public class MethodUtilsTest {
|
|||
} catch (final NoSuchMethodException expected) {
|
||||
}
|
||||
|
||||
TestBean.verify(new ImmutablePair<String, Object[]>("String...", new String[]{"x", "y"}),
|
||||
TestBean.verify(new ImmutablePair<>("String...", new String[]{"x", "y"}),
|
||||
MethodUtils.invokeMethod(testBean, "varOverloadEcho", "x", "y"));
|
||||
TestBean.verify(new ImmutablePair<String, Object[]>("Number...", new Number[]{17, 23, 42}),
|
||||
TestBean.verify(new ImmutablePair<>("Number...", new Number[]{17, 23, 42}),
|
||||
MethodUtils.invokeMethod(testBean, "varOverloadEcho", 17, 23, 42));
|
||||
TestBean.verify(new ImmutablePair<String, Object[]>("String...", new String[]{"x", "y"}),
|
||||
TestBean.verify(new ImmutablePair<>("String...", new String[]{"x", "y"}),
|
||||
MethodUtils.invokeMethod(testBean, "varOverloadEcho", "x", "y"));
|
||||
TestBean.verify(new ImmutablePair<String, Object[]>("Number...", new Number[]{17, 23, 42}),
|
||||
TestBean.verify(new ImmutablePair<>("Number...", new Number[]{17, 23, 42}),
|
||||
MethodUtils.invokeMethod(testBean, "varOverloadEcho", 17, 23, 42));
|
||||
}
|
||||
|
||||
|
@ -516,13 +516,13 @@ public class MethodUtilsTest {
|
|||
assertEquals("bar(int, String...)", MethodUtils.invokeStaticMethod(
|
||||
TestBean.class, "bar", NumberUtils.INTEGER_ONE, "a", "b"));
|
||||
|
||||
TestBean.verify(new ImmutablePair<String, Object[]>("String...", new String[]{"x", "y"}),
|
||||
TestBean.verify(new ImmutablePair<>("String...", new String[]{"x", "y"}),
|
||||
MethodUtils.invokeStaticMethod(TestBean.class, "varOverloadEchoStatic", "x", "y"));
|
||||
TestBean.verify(new ImmutablePair<String, Object[]>("Number...", new Number[]{17, 23, 42}),
|
||||
TestBean.verify(new ImmutablePair<>("Number...", new Number[]{17, 23, 42}),
|
||||
MethodUtils.invokeStaticMethod(TestBean.class, "varOverloadEchoStatic", 17, 23, 42));
|
||||
TestBean.verify(new ImmutablePair<String, Object[]>("String...", new String[]{"x", "y"}),
|
||||
TestBean.verify(new ImmutablePair<>("String...", new String[]{"x", "y"}),
|
||||
MethodUtils.invokeStaticMethod(TestBean.class, "varOverloadEchoStatic", "x", "y"));
|
||||
TestBean.verify(new ImmutablePair<String, Object[]>("Number...", new Number[]{17, 23, 42}),
|
||||
TestBean.verify(new ImmutablePair<>("Number...", new Number[]{17, 23, 42}),
|
||||
MethodUtils.invokeStaticMethod(TestBean.class, "varOverloadEchoStatic", 17, 23, 42));
|
||||
|
||||
try {
|
||||
|
|
|
@ -430,7 +430,7 @@ public class TypeUtilsTest<B> {
|
|||
final Type dClassType = AClass.class.getField("dClass").getGenericType();
|
||||
final Type eClassType = AClass.class.getField("eClass").getGenericType();
|
||||
final Type fClassType = AClass.class.getField("fClass").getGenericType();
|
||||
final AClass aClass = new AClass(new AAClass<String>());
|
||||
final AClass aClass = new AClass(new AAClass<>());
|
||||
aClass.bClass = aClass.cClass;
|
||||
assertTrue(TypeUtils.isAssignable(cClassType, bClassType));
|
||||
aClass.bClass = aClass.dClass;
|
||||
|
|
Loading…
Reference in New Issue