mirror of
https://github.com/apache/commons-collections.git
synced 2025-02-09 11:35:28 +00:00
[COLLECTIONS-453] Clone input parameters, add null check, final.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1477839 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
05f3b74fd5
commit
43e4df85bd
@ -60,7 +60,8 @@ public class InstantiateTransformer<T> implements Transformer<Class<? extends T>
|
|||||||
* @param args the constructor arguments
|
* @param args the constructor arguments
|
||||||
* @return an instantiate transformer
|
* @return an instantiate transformer
|
||||||
*/
|
*/
|
||||||
public static <T> Transformer<Class<? extends T>, T> instantiateTransformer(Class<?>[] paramTypes, Object[] args) {
|
public static <T> Transformer<Class<? extends T>, T> instantiateTransformer(final Class<?>[] paramTypes,
|
||||||
|
final Object[] args) {
|
||||||
if (((paramTypes == null) && (args != null))
|
if (((paramTypes == null) && (args != null))
|
||||||
|| ((paramTypes != null) && (args == null))
|
|| ((paramTypes != null) && (args == null))
|
||||||
|| ((paramTypes != null) && (args != null) && (paramTypes.length != args.length))) {
|
|| ((paramTypes != null) && (args != null) && (paramTypes.length != args.length))) {
|
||||||
@ -93,8 +94,8 @@ public class InstantiateTransformer<T> implements Transformer<Class<? extends T>
|
|||||||
*/
|
*/
|
||||||
public InstantiateTransformer(final Class<?>[] paramTypes, final Object[] args) {
|
public InstantiateTransformer(final Class<?>[] paramTypes, final Object[] args) {
|
||||||
super();
|
super();
|
||||||
iParamTypes = paramTypes.clone();
|
iParamTypes = paramTypes != null ? paramTypes.clone() : null;
|
||||||
iArgs = args.clone();
|
iArgs = args != null ? args.clone() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,8 +67,8 @@ public class InvokerTransformer<I, O> implements Transformer<I, O>, Serializable
|
|||||||
* @param args the arguments to pass to the method
|
* @param args the arguments to pass to the method
|
||||||
* @return an invoker transformer
|
* @return an invoker transformer
|
||||||
*/
|
*/
|
||||||
public static <I, O> Transformer<I, O> invokerTransformer(final String methodName, Class<?>[] paramTypes,
|
public static <I, O> Transformer<I, O> invokerTransformer(final String methodName, final Class<?>[] paramTypes,
|
||||||
Object[] args) {
|
final Object[] args) {
|
||||||
if (methodName == null) {
|
if (methodName == null) {
|
||||||
throw new IllegalArgumentException("The method to invoke must not be null");
|
throw new IllegalArgumentException("The method to invoke must not be null");
|
||||||
}
|
}
|
||||||
@ -80,8 +80,6 @@ public class InvokerTransformer<I, O> implements Transformer<I, O>, Serializable
|
|||||||
if (paramTypes == null || paramTypes.length == 0) {
|
if (paramTypes == null || paramTypes.length == 0) {
|
||||||
return new InvokerTransformer<I, O>(methodName);
|
return new InvokerTransformer<I, O>(methodName);
|
||||||
} else {
|
} else {
|
||||||
paramTypes = paramTypes.clone();
|
|
||||||
args = args.clone();
|
|
||||||
return new InvokerTransformer<I, O>(methodName, paramTypes, args);
|
return new InvokerTransformer<I, O>(methodName, paramTypes, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,16 +99,18 @@ public class InvokerTransformer<I, O> implements Transformer<I, O>, Serializable
|
|||||||
/**
|
/**
|
||||||
* Constructor that performs no validation.
|
* Constructor that performs no validation.
|
||||||
* Use <code>invokerTransformer</code> if you want that.
|
* Use <code>invokerTransformer</code> if you want that.
|
||||||
|
* <p>
|
||||||
|
* Note: from 4.0, the input parameters will be cloned
|
||||||
*
|
*
|
||||||
* @param methodName the method to call
|
* @param methodName the method to call
|
||||||
* @param paramTypes the constructor parameter types, not cloned
|
* @param paramTypes the constructor parameter types
|
||||||
* @param args the constructor arguments, not cloned
|
* @param args the constructor arguments
|
||||||
*/
|
*/
|
||||||
public InvokerTransformer(final String methodName, final Class<?>[] paramTypes, final Object[] args) {
|
public InvokerTransformer(final String methodName, final Class<?>[] paramTypes, final Object[] args) {
|
||||||
super();
|
super();
|
||||||
iMethodName = methodName;
|
iMethodName = methodName;
|
||||||
iParamTypes = paramTypes;
|
iParamTypes = paramTypes != null ? paramTypes.clone() : null;
|
||||||
iArgs = args;
|
iArgs = args != null ? args.clone() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user