Package org.modelmapper.spring.data
Class AggregateMappingModule
java.lang.Object
org.modelmapper.spring.data.AggregateMappingModule
- All Implemented Interfaces:
org.modelmapper.Module
ModelMapper module to allow the mapping of identifiers of variable kinds into aggregate references loadable via
Spring Data repositories. Failed aggregate resolution will be reported via an
AggregateMappingModule.AggregateReferenceMappingException unless the type has a dedicated AggregateMappingModule.NullHandling registered.- Author:
- Oliver Drotbohm
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAMappingExceptionbeing thrown in case no aggregate can be resolved for a given source value.static enum -
Constructor Summary
ConstructorsConstructorDescriptionAggregateMappingModule(org.springframework.data.repository.support.Repositories repositories, org.springframework.core.convert.ConversionService conversions) -
Method Summary
Modifier and TypeMethodDescriptiondefaultNullHandling(AggregateMappingModule.NullHandling nullHandling) Registers the givenAggregateMappingModule.NullHandlingas the one to be applied by default.Excludes the given domain type from the aggregate resolution mapping.nullHandling(Class<?> type, AggregateMappingModule.NullHandling nullHandling) Registers a dedicatedAggregateMappingModule.NullHandlingfor the given type.register(AggregateIdentifierProcessor processor) Registers anIdentifierProcessorto be used to pre- and post-process identifiers during conversions.voidsetupModule(org.modelmapper.ModelMapper mapper)
-
Constructor Details
-
AggregateMappingModule
public AggregateMappingModule(org.springframework.data.repository.support.Repositories repositories, org.springframework.core.convert.ConversionService conversions) - Parameters:
repositories- must not be null.conversions- must not be null.
-
-
Method Details
-
register
Registers anIdentifierProcessorto be used to pre- and post-process identifiers during conversions.- Parameters:
processor- must not be null.- Returns:
-
exclude
Excludes the given domain type from the aggregate resolution mapping.- Parameters:
type- must not be null.- Returns:
-
nullHandling
public AggregateMappingModule nullHandling(Class<?> type, AggregateMappingModule.NullHandling nullHandling) Registers a dedicatedAggregateMappingModule.NullHandlingfor the given type. For all other types the defaultAggregateMappingModule.NullHandlingwill be used.- Parameters:
type- must not be null.nullHandling- must not be null.- Returns:
- will never be null.
- See Also:
-
defaultNullHandling
Registers the givenAggregateMappingModule.NullHandlingas the one to be applied by default. Defaults toAggregateMappingModule.NullHandling.THROW_EXCEPTION.- Parameters:
nullHandling- must not be null.- Returns:
- will never be null.
-
setupModule
public void setupModule(org.modelmapper.ModelMapper mapper) - Specified by:
setupModulein interfaceorg.modelmapper.Module
-