Remove unnecessary array creation for varargs.

This commit is contained in:
Gary Gregory 2019-12-18 15:55:25 -05:00
parent 45763ba694
commit 8308cff798
5 changed files with 9 additions and 9 deletions

View File

@ -73,7 +73,7 @@ public class PrototypeFactory {
} catch (final NoSuchMethodException ex) {
try {
prototype.getClass().getConstructor(new Class<?>[] { prototype.getClass() });
prototype.getClass().getConstructor(prototype.getClass());
return new InstantiateFactory<>(
(Class<T>) prototype.getClass(),
new Class<?>[] { prototype.getClass() },

View File

@ -416,7 +416,7 @@ class BulkTestSuiteMaker {
private static <T> Constructor<T> getTestCaseConstructor(final Class<T> c) {
try {
return c.getConstructor(new Class[] { String.class });
return c.getConstructor(String.class);
} catch (final NoSuchMethodException e) {
throw new IllegalArgumentException(c + " must provide a (String) constructor");
}

View File

@ -182,7 +182,7 @@ public class ClosureUtilsTest {
a = new MockClosure<>();
b = new MockClosure<>();
ClosureUtils.<Object>chainedClosure(new Closure[] {a, b, a}).execute(null);
ClosureUtils.<Object>chainedClosure(a, b, a).execute(null);
assertEquals(2, a.count);
assertEquals(1, b.count);
@ -196,7 +196,7 @@ public class ClosureUtilsTest {
assertEquals(1, a.count);
assertEquals(2, b.count);
assertSame(NOPClosure.INSTANCE, ClosureUtils.<Object>chainedClosure(new Closure[0]));
assertSame(NOPClosure.INSTANCE, ClosureUtils.<Object>chainedClosure());
assertSame(NOPClosure.INSTANCE, ClosureUtils.<Object>chainedClosure(Collections.<Closure<Object>>emptyList()));
try {
@ -212,7 +212,7 @@ public class ClosureUtilsTest {
fail();
} catch (final NullPointerException ex) {}
try {
ClosureUtils.<Object>chainedClosure(new Closure[] {null, null});
ClosureUtils.<Object>chainedClosure(null, null);
fail();
} catch (final NullPointerException ex) {}
try {

View File

@ -1737,7 +1737,7 @@ public class CollectionUtilsTest extends MockTestCase {
@Test
public void addAllForElements() {
CollectionUtils.addAll(collectionA, new Integer[]{5});
CollectionUtils.addAll(collectionA, 5);
assertTrue(collectionA.contains(5));
}

View File

@ -201,13 +201,13 @@ public class TransformerUtilsTest {
assertEquals("A", TransformerUtils.chainedTransformer(b, a).transform(null));
assertEquals("B", TransformerUtils.chainedTransformer(a, b).transform(null));
assertEquals("A", TransformerUtils.chainedTransformer(new Transformer[] { b, a }).transform(null));
assertEquals("A", TransformerUtils.chainedTransformer(b, a).transform(null));
Collection<Transformer<Object, Object>> coll = new ArrayList<>();
coll.add(b);
coll.add(a);
assertEquals("A", TransformerUtils.chainedTransformer(coll).transform(null));
assertSame(NOPTransformer.INSTANCE, TransformerUtils.chainedTransformer(new Transformer[0]));
assertSame(NOPTransformer.INSTANCE, TransformerUtils.chainedTransformer());
assertSame(NOPTransformer.INSTANCE, TransformerUtils.chainedTransformer(Collections.<Transformer<Object, Object>>emptyList()));
try {
@ -223,7 +223,7 @@ public class TransformerUtilsTest {
fail();
} catch (final NullPointerException ex) {}
try {
TransformerUtils.chainedTransformer(new Transformer[] {null, null});
TransformerUtils.chainedTransformer(null, null);
fail();
} catch (final NullPointerException ex) {}
try {