Remove unnecessary array creation for varargs.
This commit is contained in:
parent
45763ba694
commit
8308cff798
|
@ -73,7 +73,7 @@ public class PrototypeFactory {
|
||||||
|
|
||||||
} catch (final NoSuchMethodException ex) {
|
} catch (final NoSuchMethodException ex) {
|
||||||
try {
|
try {
|
||||||
prototype.getClass().getConstructor(new Class<?>[] { prototype.getClass() });
|
prototype.getClass().getConstructor(prototype.getClass());
|
||||||
return new InstantiateFactory<>(
|
return new InstantiateFactory<>(
|
||||||
(Class<T>) prototype.getClass(),
|
(Class<T>) prototype.getClass(),
|
||||||
new Class<?>[] { prototype.getClass() },
|
new Class<?>[] { prototype.getClass() },
|
||||||
|
|
|
@ -416,7 +416,7 @@ class BulkTestSuiteMaker {
|
||||||
|
|
||||||
private static <T> Constructor<T> getTestCaseConstructor(final Class<T> c) {
|
private static <T> Constructor<T> getTestCaseConstructor(final Class<T> c) {
|
||||||
try {
|
try {
|
||||||
return c.getConstructor(new Class[] { String.class });
|
return c.getConstructor(String.class);
|
||||||
} catch (final NoSuchMethodException e) {
|
} catch (final NoSuchMethodException e) {
|
||||||
throw new IllegalArgumentException(c + " must provide a (String) constructor");
|
throw new IllegalArgumentException(c + " must provide a (String) constructor");
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,7 +182,7 @@ public class ClosureUtilsTest {
|
||||||
|
|
||||||
a = new MockClosure<>();
|
a = new MockClosure<>();
|
||||||
b = 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(2, a.count);
|
||||||
assertEquals(1, b.count);
|
assertEquals(1, b.count);
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ public class ClosureUtilsTest {
|
||||||
assertEquals(1, a.count);
|
assertEquals(1, a.count);
|
||||||
assertEquals(2, b.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()));
|
assertSame(NOPClosure.INSTANCE, ClosureUtils.<Object>chainedClosure(Collections.<Closure<Object>>emptyList()));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -212,7 +212,7 @@ public class ClosureUtilsTest {
|
||||||
fail();
|
fail();
|
||||||
} catch (final NullPointerException ex) {}
|
} catch (final NullPointerException ex) {}
|
||||||
try {
|
try {
|
||||||
ClosureUtils.<Object>chainedClosure(new Closure[] {null, null});
|
ClosureUtils.<Object>chainedClosure(null, null);
|
||||||
fail();
|
fail();
|
||||||
} catch (final NullPointerException ex) {}
|
} catch (final NullPointerException ex) {}
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1737,7 +1737,7 @@ public class CollectionUtilsTest extends MockTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void addAllForElements() {
|
public void addAllForElements() {
|
||||||
CollectionUtils.addAll(collectionA, new Integer[]{5});
|
CollectionUtils.addAll(collectionA, 5);
|
||||||
assertTrue(collectionA.contains(5));
|
assertTrue(collectionA.contains(5));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -201,13 +201,13 @@ public class TransformerUtilsTest {
|
||||||
|
|
||||||
assertEquals("A", TransformerUtils.chainedTransformer(b, a).transform(null));
|
assertEquals("A", TransformerUtils.chainedTransformer(b, a).transform(null));
|
||||||
assertEquals("B", TransformerUtils.chainedTransformer(a, b).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<>();
|
Collection<Transformer<Object, Object>> coll = new ArrayList<>();
|
||||||
coll.add(b);
|
coll.add(b);
|
||||||
coll.add(a);
|
coll.add(a);
|
||||||
assertEquals("A", TransformerUtils.chainedTransformer(coll).transform(null));
|
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()));
|
assertSame(NOPTransformer.INSTANCE, TransformerUtils.chainedTransformer(Collections.<Transformer<Object, Object>>emptyList()));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -223,7 +223,7 @@ public class TransformerUtilsTest {
|
||||||
fail();
|
fail();
|
||||||
} catch (final NullPointerException ex) {}
|
} catch (final NullPointerException ex) {}
|
||||||
try {
|
try {
|
||||||
TransformerUtils.chainedTransformer(new Transformer[] {null, null});
|
TransformerUtils.chainedTransformer(null, null);
|
||||||
fail();
|
fail();
|
||||||
} catch (final NullPointerException ex) {}
|
} catch (final NullPointerException ex) {}
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue