Package org.alfresco.rest.framework.core
Class ResourceInspectorUtil
- java.lang.Object
-
- org.alfresco.rest.framework.core.ResourceInspectorUtil
-
public class ResourceInspectorUtil extends java.lang.Object
Generic methods used by ResourceInspector- Author:
- Gethin James
-
-
Constructor Summary
Constructors Constructor Description ResourceInspectorUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static java.lang.Class
determineOperationType(java.lang.Class resource, java.lang.reflect.Method method)
protected static java.lang.Class
determineType(java.lang.Class resource, java.lang.reflect.Method method)
Determine the expected type as the returned type of the method.static java.util.List<java.lang.reflect.Method>
findMethodsByAnnotation(java.lang.Class objClass, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Finds methods for the given annotation It first finds all public member methods of the class or interface represented by objClass, including those inherited from superclasses and superinterfaces.static java.lang.Object
invokeMethod(java.lang.reflect.Method annotatedMethod, java.lang.Object obj)
Invokes a no arg method and returns the resultstatic java.lang.Object
invokeMethod(java.lang.reflect.Method annotatedMethod, java.lang.Object obj, java.lang.Object... args)
Invokes a method and returns the result
-
-
-
Method Detail
-
determineType
protected static java.lang.Class determineType(java.lang.Class resource, java.lang.reflect.Method method)
Determine the expected type as the returned type of the method. If the return type is a List it will return the generic element type instead of a List.- Parameters:
resource
- - resource with methodsmethod
- Method- Returns:
- Class - type of class it needs.
-
determineOperationType
protected static java.lang.Class determineOperationType(java.lang.Class resource, java.lang.reflect.Method method)
-
findMethodsByAnnotation
public static java.util.List<java.lang.reflect.Method> findMethodsByAnnotation(java.lang.Class objClass, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Finds methods for the given annotation It first finds all public member methods of the class or interface represented by objClass, including those inherited from superclasses and superinterfaces. It then loops through these methods searching for a single Annotation of annotationType, traversing its super methods if no annotation can be found on the given method itself.- Parameters:
objClass
- - the classannotationType
- - the annotation to find- Returns:
- - the List of Method or an empty List
-
invokeMethod
public static java.lang.Object invokeMethod(java.lang.reflect.Method annotatedMethod, java.lang.Object obj)
Invokes a no arg method and returns the result- Parameters:
annotatedMethod
- Methodobj
- Object- Returns:
- result of method call
-
invokeMethod
public static java.lang.Object invokeMethod(java.lang.reflect.Method annotatedMethod, java.lang.Object obj, java.lang.Object... args) throws java.lang.Throwable
Invokes a method and returns the result- Parameters:
annotatedMethod
- Methodobj
- Object- Returns:
- result of method call
- Throws:
java.lang.Throwable
-
-