Class MethodUtil


  • public final class MethodUtil
    extends java.lang.Object
    MethodUtils
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <A> java.lang.reflect.Method getGetter​(A instance, java.lang.String strAttributeName, java.lang.Class<?> clazz)
      Gets the setter.
      static <A> java.lang.reflect.Method getMethod​(java.lang.String strMethodPrefix, A instance, java.lang.String strAttributeName, java.lang.Class<?> clazz)
      Gets the method.
      static <A> java.lang.reflect.Method getPrimitiveMethod​(java.lang.String strMethodName, A instance, java.lang.Class<?> clazz)
      Gets the primitive method.
      static <A> java.lang.reflect.Method getSetter​(A instance, java.lang.String strAttributeName, java.lang.Class<?> clazz)
      Gets the setter.
      static <A,​B>
      void
      set​(A instance, java.lang.String strAttributeName, B value)
      Sets the attribute.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • set

        public static <A,​B> void set​(A instance,
                                           java.lang.String strAttributeName,
                                           B value)
                                    throws java.lang.NoSuchMethodException,
                                           java.lang.IllegalAccessException,
                                           java.lang.reflect.InvocationTargetException
        Sets 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 instance
        B - the generic type of the value to set
        Parameters:
        instance - the instance to set
        strAttributeName - the attribute name
        value - the value of the attribute to set
        Throws:
        java.lang.SecurityException - the security exception
        java.lang.NoSuchMethodException - the no such method exception
        java.lang.IllegalArgumentException - the illegal argument exception
        java.lang.IllegalAccessException - the illegal access exception
        java.lang.reflect.InvocationTargetException - the invocation target exception
      • getMethod

        public static <A> java.lang.reflect.Method getMethod​(java.lang.String strMethodPrefix,
                                                             A instance,
                                                             java.lang.String strAttributeName,
                                                             java.lang.Class<?> clazz)
                                                      throws java.lang.NoSuchMethodException
        Gets the method.
        Type Parameters:
        A - the generic type of the instance
        Parameters:
        strMethodPrefix - the str method prefix
        instance - the instance
        strAttributeName - the str attribute name
        clazz - the clazz
        Returns:
        the method
        Throws:
        java.lang.SecurityException - the security exception
        java.lang.NoSuchMethodException - the no such method exception
      • getPrimitiveMethod

        public static <A> java.lang.reflect.Method getPrimitiveMethod​(java.lang.String strMethodName,
                                                                      A instance,
                                                                      java.lang.Class<?> clazz)
                                                               throws java.lang.NoSuchMethodException
        Gets the primitive method.
        Type Parameters:
        A - the generic type of the instance
        Parameters:
        strMethodName - the str method name
        instance - the instance
        clazz - the clazz
        Returns:
        the primitive method
        Throws:
        java.lang.SecurityException - the security exception
        java.lang.NoSuchMethodException - the no such method exception
      • getSetter

        public static <A> java.lang.reflect.Method getSetter​(A instance,
                                                             java.lang.String strAttributeName,
                                                             java.lang.Class<?> clazz)
                                                      throws java.lang.NoSuchMethodException
        Gets the setter.
        Type Parameters:
        A - the generic type
        Parameters:
        instance - the instance
        strAttributeName - the str attribute name
        clazz - the clazz
        Returns:
        the setter
        Throws:
        java.lang.SecurityException - the security exception
        java.lang.NoSuchMethodException - the no such method exception
      • getGetter

        public static <A> java.lang.reflect.Method getGetter​(A instance,
                                                             java.lang.String strAttributeName,
                                                             java.lang.Class<?> clazz)
                                                      throws java.lang.NoSuchMethodException
        Gets the setter.
        Type Parameters:
        A - the generic type of the instance
        Parameters:
        instance - the instance
        strAttributeName - the str attribute name
        clazz - the clazz
        Returns:
        the setter
        Throws:
        java.lang.SecurityException - the security exception
        java.lang.NoSuchMethodException - the no such method exception