-
Notifications
You must be signed in to change notification settings - Fork 41
Immutable Objects
Alessandro Vurro edited this page Oct 25, 2016
·
7 revisions
What changes if you have a target object that is not instantiable? Nothing!
Since 1.6.1.RC1 version you can pass the immutable object to the getDestination method using the enrichment signature:
ImmutableObj obj = ....
...
obj = mapper.getDestination(obj, source);
...
Nothing is changed from the developer's point of view, empty constructor is not longer mandatory.
In addition to this, there is the possibility to delegate the management to JMapper through destinationFactory
method:
mapper.destinationFactory(new DestinationFactory<NotEmptyConstructor>() {
@Override
public NotEmptyConstructor make() {
return new NotEmptyConstructor("fields");
}
});
// or in java 8+
// mapper.destinationFactory(() -> new NotEmptyConstructor("fields"));
This comes in handy when the mapper is used in several points, thus avoiding to take the immutable object around.
IMPORTANT! for the moment It is not provided the management of the internal immutable objects.
© 2016 Alessandro Vurro
- Home
- How to map
- Relations
- Conversions
- creation/enrichment
- XML
- Annotation
- API
- Configurations
- Utilities
- Examples
- Articles
- More information
- Performance tests
- Release Notes