Class ModelHelper
java.lang.Object
io.helidon.microprofile.grpc.core.ModelHelper
Common model helper methods.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Method
findMethodOnClass
(Class<?> cls, Method m) Find a method in a class.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<?>
Get Array class of component type.static Collection<? extends Method>
getDeclaredMethods
(Class<?> clazz) Get collection of 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 Details
-
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.
-
getDeclaredMethods
Get collection of methods declared on given class.- Parameters:
clazz
- class for which to get the declared methods.- Returns:
- methods declared on the
clazz
class.
-
findMethodOnClass
Find a method in a class. If there exists a public method on the class that has the same name and parameters then that public method is returned.Otherwise, if there exists a public method on the class that has the same name and the same number of parameters, and each generic parameter type, in order, of the public method is equal to the generic parameter type, in the same order or is an instance of
TypeVariable
then that public method is returned.- Parameters:
cls
- the class to search for a public methodm
- the method to find- Returns:
- public method found.
-
getArrayComponentType
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
Get Array class of component type.- Parameters:
c
- the component class of the array- Returns:
- the array class.
-
getMarshallerSupplier
Obtain the namedMarshallerSupplier
specified by the annotation.- Parameters:
annotation
- the annotation specifying theMarshallerSupplier
.- Returns:
- the
MarshallerSupplier
specified by the annotation
-
getGenericType
Obtain the generic type for aType
.- Parameters:
type
- the type to obtain the generic type of- Returns:
- the generic type
-