[LANG-1564] use Collections.singletonList insteadof Arrays.asList when there be only one element. (#549)
* asList * Update TypeUtilsTest.java
This commit is contained in:
parent
386c1e2f37
commit
f2d376ae01
|
@ -19,6 +19,7 @@ package org.apache.commons.lang3.text.translate;
|
|||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
|
||||
/**
|
||||
|
@ -62,7 +63,7 @@ public class NumericEntityUnescaper extends CharSequenceTranslator {
|
|||
if (options.length > 0) {
|
||||
this.options = EnumSet.copyOf(Arrays.asList(options));
|
||||
} else {
|
||||
this.options = EnumSet.copyOf(Arrays.asList(OPTION.semiColonRequired));
|
||||
this.options = EnumSet.copyOf(Collections.singletonList(OPTION.semiColonRequired));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -243,10 +243,10 @@ public class ObjectUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testHashCodeMulti_multiple_likeList() {
|
||||
final List<Object> list0 = new ArrayList<>(Arrays.asList());
|
||||
final List<Object> list0 = new ArrayList<>(Collections.emptyList());
|
||||
assertEquals(list0.hashCode(), ObjectUtils.hashCodeMulti());
|
||||
|
||||
final List<Object> list1 = new ArrayList<>(Arrays.asList("a"));
|
||||
final List<Object> list1 = new ArrayList<>(Collections.singletonList("a"));
|
||||
assertEquals(list1.hashCode(), ObjectUtils.hashCodeMulti("a"));
|
||||
|
||||
final List<Object> list2 = new ArrayList<>(Arrays.asList("a", "b"));
|
||||
|
|
|
@ -32,7 +32,6 @@ import java.lang.reflect.TypeVariable;
|
|||
import java.lang.reflect.WildcardType;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -504,7 +503,7 @@ public class TypeUtilsTest<B> {
|
|||
assertEquals(Integer.class, typeVarAssigns.get(treeSetTypeVar),
|
||||
"Type argument of Comparable from int: " + typeArg);
|
||||
|
||||
final Collection<Integer> col = Arrays.asList();
|
||||
final Collection<Integer> col = Collections.emptyList();
|
||||
typeVarAssigns = TypeUtils.getTypeArguments(List.class, Collection.class);
|
||||
treeSetTypeVar = Comparable.class.getTypeParameters()[0];
|
||||
assertFalse(typeVarAssigns.containsKey(treeSetTypeVar),
|
||||
|
|
Loading…
Reference in New Issue