java.lang.Object
io.helidon.microprofile.grpc.core.ModelHelper

public final class ModelHelper extends Object
Common model helper methods.
  • 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 class
      annotation - the annotation to look for
      Returns:
      resource class or it's ancestor that is annotated with the specified annotation.
    • getDeclaredMethods

      public static Collection<? extends Method> getDeclaredMethods(Class<?> clazz)
      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

      public static Method findMethodOnClass(Class<?> cls, Method m)
      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 method
      m - the method to find
      Returns:
      public method found.
    • 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 named MarshallerSupplier specified by the annotation.
      Parameters:
      annotation - the annotation specifying the MarshallerSupplier.
      Returns:
      the MarshallerSupplier specified by the annotation
    • getGenericType

      public static Class<?> getGenericType(Type type)
      Obtain the generic type for a Type.
      Parameters:
      type - the type to obtain the generic type of
      Returns:
      the generic type