Package fr.paris.lutece.util.method
Class MethodUtil
- java.lang.Object
-
- fr.paris.lutece.util.method.MethodUtil
-
public final class MethodUtil extends Object
MethodUtils
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <A> MethodgetGetter(A instance, String strAttributeName, Class<?> clazz)Gets the setter.static <A> MethodgetMethod(String strMethodPrefix, A instance, String strAttributeName, Class<?> clazz)Gets the method.static <A> MethodgetPrimitiveMethod(String strMethodName, A instance, Class<?> clazz)Gets the primitive method.static <A> MethodgetSetter(A instance, String strAttributeName, Class<?> clazz)Gets the setter.static <A,B>
voidset(A instance, String strAttributeName, B value)Sets the attribute.
-
-
-
Method Detail
-
set
public static <A,B> void set(A instance, String strAttributeName, B value) throws NoSuchMethodException, IllegalAccessException, InvocationTargetExceptionSets the attribute.
Warning : This method does not handle setter that :- has no parameter or has more than one parameter
- has array parameter (ie : String[] or int[] ...)
- Type Parameters:
A- the generic type of the instanceB- the generic type of the value to set- Parameters:
instance- the instance to setstrAttributeName- the attribute namevalue- the value of the attribute to set- Throws:
SecurityException- the security exceptionNoSuchMethodException- the no such method exceptionIllegalArgumentException- the illegal argument exceptionIllegalAccessException- the illegal access exceptionInvocationTargetException- the invocation target exception
-
getMethod
public static <A> Method getMethod(String strMethodPrefix, A instance, String strAttributeName, Class<?> clazz) throws NoSuchMethodException
Gets the method.- Type Parameters:
A- the generic type of the instance- Parameters:
strMethodPrefix- the str method prefixinstance- the instancestrAttributeName- the str attribute nameclazz- the clazz- Returns:
- the method
- Throws:
SecurityException- the security exceptionNoSuchMethodException- the no such method exception
-
getPrimitiveMethod
public static <A> Method getPrimitiveMethod(String strMethodName, A instance, Class<?> clazz) throws NoSuchMethodException
Gets the primitive method.- Type Parameters:
A- the generic type of the instance- Parameters:
strMethodName- the str method nameinstance- the instanceclazz- the clazz- Returns:
- the primitive method
- Throws:
SecurityException- the security exceptionNoSuchMethodException- the no such method exception
-
getSetter
public static <A> Method getSetter(A instance, String strAttributeName, Class<?> clazz) throws NoSuchMethodException
Gets the setter.- Type Parameters:
A- the generic type- Parameters:
instance- the instancestrAttributeName- the str attribute nameclazz- the clazz- Returns:
- the setter
- Throws:
SecurityException- the security exceptionNoSuchMethodException- the no such method exception
-
getGetter
public static <A> Method getGetter(A instance, String strAttributeName, Class<?> clazz) throws NoSuchMethodException
Gets the setter.- Type Parameters:
A- the generic type of the instance- Parameters:
instance- the instancestrAttributeName- the str attribute nameclazz- the clazz- Returns:
- the setter
- Throws:
SecurityException- the security exceptionNoSuchMethodException- the no such method exception
-
-