Class AnnotationUtils

java.lang.Object
org.restlet.engine.resource.AnnotationUtils

public class AnnotationUtils extends Object
Utilities to manipulate Restlet annotations.
Author:
Jerome Louvel
  • Constructor Details

    • AnnotationUtils

      protected AnnotationUtils()
      Protected constructor.
  • Method Details

    • getInstance

      public static AnnotationUtils getInstance()
      Returns the current instance of AnnotationUtils.
    • clearCache

      public void clearCache()
      Clears the annotation descriptors cache.
    • getAnnotations

      public List<AnnotationInfo> getAnnotations(Class<?> clazz)
      Returns the annotation descriptors for the given resource class.
      Parameters:
      clazz - The resource class to introspect.
      Returns:
      The list of annotation descriptors.
    • getAnnotations

      public List<AnnotationInfo> getAnnotations(Class<?> clazz, Method javaMethod)
      Returns the annotation descriptors for the given resource class.
      Parameters:
      javaMethod - The Java method.
      Returns:
      The list of annotation descriptors.
    • getMethodAnnotation

      public MethodAnnotationInfo getMethodAnnotation(List<AnnotationInfo> annotations, Method javaMethod)
      Returns the first annotation descriptor matching the given Java method.
      Parameters:
      annotations - The list of annotations.
      javaMethod - The method to match.
      Returns:
      The annotation descriptor.
    • getMethodAnnotation

      public MethodAnnotationInfo getMethodAnnotation(List<AnnotationInfo> annotations, Method restletMethod, Form query, Representation entity, MetadataService metadataService, ConverterService converterService) throws IOException
      Returns the first annotation descriptor matching the given Restlet method.
      Parameters:
      annotations - The list of annotations.
      restletMethod - The method to match.
      query - The query parameters.
      entity - The request entity to match or null if no entity is provided.
      metadataService - The metadata service to use.
      converterService - The converter service to use.
      Returns:
      The annotation descriptor.
      Throws:
      IOException
    • getRestletMethod

      protected Method getRestletMethod(Annotation annotation, Annotation methodAnnotation)
      Returns an instance of Method according to the given annotations.
      Parameters:
      annotation - Java annotation.
      methodAnnotation - Annotation that corresponds to a Restlet method.
      Returns:
      An instance of Method according to the given annotations.
    • getThrowableAnnotationInfo

      public ThrowableAnnotationInfo getThrowableAnnotationInfo(Class<?> clazz)
      Returns the status annotation descriptor if present or null.
      Parameters:
      clazz - The class with the status attached.
      Returns:
      The status annotation descriptor if present or null.
    • getThrowableAnnotationInfo

      public ThrowableAnnotationInfo getThrowableAnnotationInfo(Method javaMethod, int errorCode)
      Returns the Throwable class matching the given error code if present or null.
      Parameters:
      javaMethod - The method that holds Throwable.
      errorCode - The error code to match.
      Returns:
      The Throwable class matching the given error code if present or null.
    • getThrowableClass

      public Class<?> getThrowableClass(Method javaMethod, int errorCode)
      Returns the Throwable class matching the given error code if present or null.
      Parameters:
      javaMethod - The method that holds Throwable.
      errorCode - The error code to match.
      Returns:
      The Throwable class matching the given error code if present or null.