Spring Hateoas

org.springframework.hateoas.core
Class AnnotationMappingDiscoverer

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

public class AnnotationMappingDiscoverer
extends Object
implements MappingDiscoverer

MappingDiscoverer implementation that inspects mappings from a particular annotation.

Author:
Oliver Gierke

Constructor Summary
AnnotationMappingDiscoverer(Class<? extends Annotation> annotation)
          Creates an AnnotationMappingDiscoverer for the given annotation type.
AnnotationMappingDiscoverer(Class<? extends Annotation> annotation, String mappingAttributeName)
          Creates an AnnotationMappingDiscoverer for the given annotation type and attribute name.
 
Method Summary
 String getMapping(Class<?> type)
          Returns the mapping associated with the given type.
 String getMapping(Class<?> type, Method method)
          Returns the mapping for the given Method invoked on the given type.
 String getMapping(Method method)
          Returns the mapping associated with the given Method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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,
                                   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 Detail

getMapping

public String getMapping(Class<?> type)
Description copied from interface: MappingDiscoverer
Returns the mapping associated with the given type.

Specified by:
getMapping in interface MappingDiscoverer
Parameters:
type - must not be null.
Returns:
the type-level mapping or null in case none is present.

getMapping

public String getMapping(Method method)
Description copied from interface: MappingDiscoverer
Returns the mapping associated with the given Method. This will include the type-level mapping.

Specified by:
getMapping 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.

getMapping

public String getMapping(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:
getMapping 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.

Spring Hateoas

Copyright © 2012-2014-2014 Pivotal, Inc.. All Rights Reserved.