Class AnnotationMappingDiscoverer

java.lang.Object
org.springframework.hateoas.server.core.AnnotationMappingDiscoverer
All Implemented Interfaces:
MappingDiscoverer

public class AnnotationMappingDiscoverer extends Object
MappingDiscoverer implementation that inspects mappings from a particular annotation.
Author:
Oliver Gierke, Mark Paluch, Greg Turnquist, Réda Housni Alaoui
  • Constructor Details

    • AnnotationMappingDiscoverer

      public AnnotationMappingDiscoverer(Class<? extends Annotation> annotation)
      Creates an AnnotationMappingDiscoverer for the given annotation type. Will lookup the value attribute by default.
      Parameters:
      annotation - must not be null.
    • AnnotationMappingDiscoverer

      public AnnotationMappingDiscoverer(Class<? extends Annotation> annotation, @Nullable String mappingAttributeName)
      Creates an AnnotationMappingDiscoverer for the given annotation type and attribute name.
      Parameters:
      annotation - must not be null.
      mappingAttributeName - if null, it defaults to value.
  • Method Details

    • getUriMapping

      public @Nullable UriMapping getUriMapping(Class<?> type)
      Description copied from interface: MappingDiscoverer
      Returns the mapping associated with the given type.
      Specified by:
      getUriMapping in interface MappingDiscoverer
      Parameters:
      type - must not be null.
      Returns:
      the type-level mapping or null in case none is present.
    • getUriMapping

      public @Nullable UriMapping getUriMapping(Method method)
      Description copied from interface: MappingDiscoverer
      Returns the mapping associated with the given Method. This will include the type-level mapping.
      Specified by:
      getUriMapping in interface MappingDiscoverer
      Parameters:
      method - must not be null.
      Returns:
      the method mapping including the type-level one or null if neither of them present.
    • getUriMapping

      public @Nullable UriMapping getUriMapping(Class<?> type, Method method)
      Description copied from interface: MappingDiscoverer
      Returns the mapping for the given Method invoked on the given type. This can be used to calculate the mapping for a super type method being invoked on a sub-type with a type mapping.
      Specified by:
      getUriMapping in interface MappingDiscoverer
      Parameters:
      type - must not be null.
      method - must not be null.
      Returns:
      the method mapping including the type-level one or null if neither of them present.
    • getMapping

      public @Nullable String getMapping(@Nullable Class<?> type, @Nullable Method method)
    • getRequestMethod

      public Collection<org.springframework.http.HttpMethod> getRequestMethod(Class<?> type, Method method)
      Extract RequestMapping's list of RequestMethods into an array of Strings.
      Specified by:
      getRequestMethod in interface MappingDiscoverer
      Parameters:
      type -
      method -
      Returns:
    • getConsumes

      public List<org.springframework.http.MediaType> getConsumes(Method method)
      Description copied from interface: MappingDiscoverer
      Returns the MediaTypes supported for consumption.
      Specified by:
      getConsumes in interface MappingDiscoverer
      Parameters:
      method - must not be null.
      Returns:
      can be null.
    • getParams

      public String[] getParams(Method method)
      Description copied from interface: MappingDiscoverer
      Returns the statically declared request parameters.
      Specified by:
      getParams in interface MappingDiscoverer
      Parameters:
      method - must not be null.
      Returns:
      the parameters of the mapped request, narrowing the primary mapping.