Class ModelHelper
- java.lang.Object
-
- io.helidon.microprofile.grpc.core.ModelHelper
-
public final class ModelHelper extends Object
Common model helper methods.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static PrivilegedAction<Method>
findMethodOnClassPA(Class<?> cls, Method m)
Get privileged action to find a method on a class given an existing method.static Class<?>
getAnnotatedResourceClass(Class<?> resourceClass, Class<? extends Annotation> annotation)
Get the class in the provided resource class ancestor hierarchy that is actually annotated with the specified annotation.static Type
getArrayComponentType(Type type)
Gets the component type of the array.static Class<?>
getArrayForComponentType(Class<?> c)
Get Array class of component type.static PrivilegedAction<Collection<? extends Method>>
getDeclaredMethodsPA(Class<?> clazz)
Get privileged action to obtain methods declared on given class.static Class<?>
getGenericType(Type type)
Obtain the generic type for aType
.static MarshallerSupplier
getMarshallerSupplier(GrpcMarshaller annotation)
Obtain the namedMarshallerSupplier
specified by the annotation.
-
-
-
Method Detail
-
getAnnotatedResourceClass
public static Class<?> getAnnotatedResourceClass(Class<?> resourceClass, Class<? extends Annotation> annotation)
Get the class in the provided resource class ancestor hierarchy that is actually annotated with the specified annotation.If the annotation is not present in the class hierarchy the resource class is returned.
- Parameters:
resourceClass
- resource classannotation
- the annotation to look for- Returns:
- resource class or it's ancestor that is annotated with the specified annotation.
-
getDeclaredMethodsPA
public static PrivilegedAction<Collection<? extends Method>> getDeclaredMethodsPA(Class<?> clazz)
Get privileged action to obtain methods declared on given class. If run using security manager, the returned privileged action must be invoked within a doPrivileged block.- Parameters:
clazz
- class for which to get the declared methods.- Returns:
- privileged action to obtain methods declared on the
clazz
class. - See Also:
AccessController.doPrivileged(java.security.PrivilegedAction)
-
findMethodOnClassPA
public static PrivilegedAction<Method> findMethodOnClassPA(Class<?> cls, Method m)
Get privileged action to find a method on a class given an existing method. If run using security manager, the returned privileged action must be invoked within a doPrivileged block.If there exists a public method on the class that has the same name and parameters as the existing method then that public method is returned from the action.
Otherwise, if there exists a public method on the class that has the same name and the same number of parameters as the existing method, and each generic parameter type, in order, of the public method is equal to the generic parameter type, in the same order, of the existing method or is an instance of
TypeVariable
then that public method is returned from the action.- Parameters:
cls
- the class to search for a public methodm
- the method to find- Returns:
- privileged action to return public method found.
- See Also:
AccessController.doPrivileged(java.security.PrivilegedAction)
-
getArrayComponentType
public static Type getArrayComponentType(Type type)
Gets the component type of the array.- Parameters:
type
- must be an array.- Returns:
- array component type.
- Throws:
IllegalArgumentException
- in case the type is not an array type.
-
getArrayForComponentType
public static Class<?> getArrayForComponentType(Class<?> c)
Get Array class of component type.- Parameters:
c
- the component class of the array- Returns:
- the array class.
-
getMarshallerSupplier
public static MarshallerSupplier getMarshallerSupplier(GrpcMarshaller annotation)
Obtain the namedMarshallerSupplier
specified by the annotation.- Parameters:
annotation
- the annotation specifying theMarshallerSupplier
.- Returns:
- the
MarshallerSupplier
specified by the annotation
-
-