Class JpaMapperUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic <S,
D> List<D> populateOrInitializeList
(org.modelmapper.ModelMapper mapper, org.modelmapper.spi.MappingContext<List<S>, List<D>> mappingContext, Class<D> destinationElementType) This method is intended to be used within aConverter
for a property mapping between twoList
fields.static <S,
D> List<D> populateOrInitializeList
(org.modelmapper.spi.MappingContext<List<S>, List<D>> mappingContext, Function<S, D> destinationFactory) This method is intended to be used within aConverter
for a property mapping between twoList
fields.static <S,
D> List<D> populateOrInitializeListFromSet
(org.modelmapper.spi.MappingContext<Set<S>, List<D>> mappingContext, Function<S, D> destinationFactory) This method is intended to be used within aConverter
for a property mapping between a Set and List fields.static <S,
D> Set<D> populateOrInitializeSet
(org.modelmapper.ModelMapper mapper, org.modelmapper.spi.MappingContext<Set<S>, Set<D>> mappingContext, Class<D> destinationElementType) This method is intended to be used within aConverter
for a property mapping between twoSet
fields.static <S,
D> Set<D> populateOrInitializeSet
(org.modelmapper.spi.MappingContext<Set<S>, Set<D>> mappingContext, Function<S, D> destinationFactory) This method is intended to be used within aConverter
for a property mapping between twoSet
fields.
-
Method Details
-
populateOrInitializeSet
public static <S,D> Set<D> populateOrInitializeSet(org.modelmapper.ModelMapper mapper, org.modelmapper.spi.MappingContext<Set<S>, Set<D>> mappingContext, Class<D> destinationElementType) This method is intended to be used within aConverter
for a property mapping between twoSet
fields.If the destination field is null, then it will initialize its value to a new LinkedHashSet instance before performing the per-element mapping.
If the destination field is not null, then it will preserve the existing instance and simply clear its contents before performing the per-element mapping. Preserving the existing instance reference is important particularly for scenarios where it is a Hibernate proxy.
- Type Parameters:
S
- the type of the elements in the source fieldD
- the type of the elements in the destination field- Parameters:
mapper
- aModelMapper
instance that already contains aTypeMap
from the source element type to the destination element type. It will be used for per-element mapping.mappingContext
- the mapping context provided to theConverter
destinationElementType
- the type of the elements in the destination field- Returns:
- the destination field value after performing necessary initializations and mapping
-
populateOrInitializeSet
public static <S,D> Set<D> populateOrInitializeSet(org.modelmapper.spi.MappingContext<Set<S>, Set<D>> mappingContext, Function<S, D> destinationFactory) This method is intended to be used within aConverter
for a property mapping between twoSet
fields.If the destination field is null, then it will initialize its value to a new LinkedHashSet instance before performing the per-element mapping.
If the destination field is not null, then it will preserve the existing instance and simply clear its contents before performing the per-element mapping. Preserving the existing instance reference is important particularly for scenarios where it is a Hibernate proxy.
- Type Parameters:
S
- the type of the elements in the source fieldD
- the type of the elements in the destination field- Parameters:
mappingContext
- the mapping context provided to theConverter
destinationFactory
- The Function responsible for creating the destination instance- Returns:
- the destination field value after performing necessary initializations and mapping
-
populateOrInitializeList
public static <S,D> List<D> populateOrInitializeList(org.modelmapper.ModelMapper mapper, org.modelmapper.spi.MappingContext<List<S>, List<D>> mappingContext, Class<D> destinationElementType) This method is intended to be used within aConverter
for a property mapping between twoList
fields.If the destination field is null, then it will initialize its value to a new ArrayList instance before performing the per-element mapping.
If the destination field is not null, then it will preserve the existing instance and simply clear its contents before performing the per-element mapping. Preserving the existing instance reference is important particularly for scenarios where it is a Hibernate proxy.
- Type Parameters:
S
- the type of the elements in the source fieldD
- the type of the elements in the destination field- Parameters:
mapper
- aModelMapper
instance that already contains aTypeMap
from the source element type to the destination element type. It will be used for per-element mapping.mappingContext
- the mapping context provided to theConverter
destinationElementType
- the type of the elements in the destination field- Returns:
- the destination field value after performing necessary initializations and mapping
-
populateOrInitializeList
public static <S,D> List<D> populateOrInitializeList(org.modelmapper.spi.MappingContext<List<S>, List<D>> mappingContext, Function<S, D> destinationFactory) This method is intended to be used within aConverter
for a property mapping between twoList
fields.If the destination field is null, then it will initialize its value to a new ArrayList instance before performing the per-element mapping.
If the destination field is not null, then it will preserve the existing instance and simply clear its contents before performing the per-element mapping. Preserving the existing instance reference is important particularly for scenarios where it is a Hibernate proxy.
- Type Parameters:
S
- the type of the elements in the source fieldD
- the type of the elements in the destination field- Parameters:
mappingContext
- the mapping context provided to theConverter
destinationFactory
- The Function responsible for creating the destination instance- Returns:
- the destination field value after performing necessary initializations and mapping
-
populateOrInitializeListFromSet
public static <S,D> List<D> populateOrInitializeListFromSet(org.modelmapper.spi.MappingContext<Set<S>, List<D>> mappingContext, Function<S, D> destinationFactory) This method is intended to be used within aConverter
for a property mapping between a Set and List fields.If the destination field is null, then it will initialize its value to a new ArrayList instance before performing the per-element mapping.
If the destination field is not null, then it will preserve the existing instance and simply clear its contents before performing the per-element mapping. Preserving the existing instance reference is important particularly for scenarios where it is a Hibernate proxy.
- Type Parameters:
S
- the type of the elements in the source fieldD
- the type of the elements in the destination field- Parameters:
mappingContext
- the mapping context provided to theConverter
destinationFactory
- The Function responsible for creating the destination instance- Returns:
- the destination field value after performing necessary initializations and mapping
-