Class UriTemplateIdentifierProcessor

java.lang.Object
org.modelmapper.spring.data.UriTemplateIdentifierProcessor
All Implemented Interfaces:
AggregateIdentifierProcessor, org.springframework.plugin.core.Plugin<Class<?>>

public class UriTemplateIdentifierProcessor extends Object implements AggregateIdentifierProcessor
An IdentifierProcessor that allows to register UriTemplates for aggregate types so that the model mapping is able to extract the actual aggregate identifier from URIs.
Author:
Oliver Drotbohm
  • Constructor Details

    • UriTemplateIdentifierProcessor

      public UriTemplateIdentifierProcessor()
  • Method Details

    • register

      public UriTemplateIdentifierProcessor register(Class<?> type, String uriTemplate)
      Registers the given URI template for the given aggregate type. Assumes a single URI template parameter be in place.
      Parameters:
      type - must not be null.
      uriTemplate - must not be null or empty.
      Returns:
      will never be null.
    • register

      public UriTemplateIdentifierProcessor register(Class<?> type, org.springframework.web.util.UriTemplate template)
      Registers the given URI template for the given aggregate type. Assumes a single URI template parameter be in place.
      Parameters:
      type - must not be null.
      uriTemplate - must not be null.
      Returns:
      will never be null.
    • register

      public UriTemplateIdentifierProcessor register(Class<?> type, org.springframework.web.util.UriTemplate template, String variableName)
      Registers the given UriTemplate and template variable name for the given aggregate type.
      Parameters:
      type - must not be null.
      template - must not be null.
      variableName - must not be null or empty.
      Returns:
      will never be null.
    • preProcessIdentifier

      public Object preProcessIdentifier(Object identifier, Class<?> targetType)
      Description copied from interface: AggregateIdentifierProcessor
      Pre-process the identifier obtained from the source object to finally resolve an aggregate from the returned value.
      Specified by:
      preProcessIdentifier in interface AggregateIdentifierProcessor
      Parameters:
      identifier - the original identifier obtained from the source object. Must not be null.
      targetType - the target aggregate type the given identifier is supposed to eventually identify. Must not be null.
      Returns:
      will never be null.
    • postProcessIdentifier

      public Object postProcessIdentifier(Object identifier, Class<?> sourceType, Class<?> targetType)
      Description copied from interface: AggregateIdentifierProcessor
      Post process the identifier obtained from the aggregate to finally constitute the value to be set on the target object.
      Specified by:
      postProcessIdentifier in interface AggregateIdentifierProcessor
      Parameters:
      identifier - the original identifier of the aggregate to be transformed into the target object's property value. Must not be null.
      sourceType - the source aggregate type. Must not be null.
      targetType - the target type to create for this aggregate. Can be used to decide whether to actually apply post-processing.
      Returns:
      will never be null.
    • getAdditionalIdentifierTypes

      public Collection<Class<?>> getAdditionalIdentifierTypes()
      Description copied from interface: AggregateIdentifierProcessor
      Returns additional identifier types that the processor will be able to handle.
      Specified by:
      getAdditionalIdentifierTypes in interface AggregateIdentifierProcessor
      Returns:
      will never be null.
    • supports

      public boolean supports(Class<?> delimiter)
      Specified by:
      supports in interface org.springframework.plugin.core.Plugin<Class<?>>