Skip to content

Enumerations

avurro edited this page Jul 24, 2015 · 10 revisions

There are two enumerations that help the developer to simplify the work and they are: NullPointerControl and MappingType.
This enumerations allow you to control instances in input and apply a logical mapping specification.
They are passed as input to getDestination, manyToOne and oneToMany methods.

NullPointerControl

This enumeration verifies that the objects passed in input are valued, if not, a null will be returned.
The values of NullPointerControl are:
NullPointerControl.DESTINATION only destination will be controlled
NullPointerControl.SOURCE only source will be controlled
NullPointerControl.ALL both instances will be checked
NullPointerControl.NOT_ANY neither

MappingType

This enumeration allows you to define which mode of mapping to apply.
This feature is useful when you want to enrich destination.
MappingType can be used for both instances.

IMPORTANT! JMapper not apply these mapping types to primitive variables, because they can not be null

The values of MappingType are:

MappingType.ALL_FIELDS all fields will be included in the mapping
MappingType.ONLY_VALUED_FIELDS only valued fields will be included in the mapping
MappingType.ONLY_NULL_FIELDS only null fields will be included in the mapping

the possible combinations are summarized in the following table:

destinationField = "DESTINATION"
sourceField = "SOURCE"
Destination MappingType Source MappingType Destination field
ALL_FIELDS ALL_FIELDS "SOURCE"
ONLY_VALUED_FIELDS ALL_FIELDS "SOURCE"
ONLY_NULL_FIELDS ALL_FIELDS "DESTINATION"
ALL_FIELDS ONLY_VALUED_FIELDS "SOURCE"
ONLY_VALUED_FIELDS ONLY_VALUED_FIELDS "SOURCE"
ONLY_NULL_FIELDS ONLY_VALUED_FIELDS "DESTINATION"
ALL_FIELDS ONLY_NULL_FIELDS "DESTINATION"
ONLY_VALUED_FIELDS ONLY_NULL_FIELDS "DESTINATION"
ONLY_NULL_FIELDS ONLY_NULL_FIELDS "DESTINATION"
destinationField = null
sourceField = "SOURCE"
Destination MappingType Source MappingType Destination field
ALL_FIELDS ALL_FIELDS "SOURCE"
ONLY_VALUED_FIELDS ALL_FIELDS null
ONLY_NULL_FIELDS ALL_FIELDS "SOURCE"
ALL_FIELDS ONLY_VALUED_FIELDS "SOURCE"
ONLY_VALUED_FIELDS ONLY_VALUED_FIELDS null
ONLY_NULL_FIELDS ONLY_VALUED_FIELDS "SOURCE"
ALL_FIELDS ONLY_NULL_FIELDS null
ONLY_VALUED_FIELDS ONLY_NULL_FIELDS null
ONLY_NULL_FIELDS ONLY_NULL_FIELDS null
destinationField = "DESTINATION"
sourceField = null
Destination MappingType Source MappingType Destination field
ALL_FIELDS ALL_FIELDS null
ONLY_VALUED_FIELDS ALL_FIELDS null
ONLY_NULL_FIELDS ALL_FIELDS "DESTINATION"
ALL_FIELDS ONLY_VALUED_FIELDS "DESTINATION"
ONLY_VALUED_FIELDS ONLY_VALUED_FIELDS "DESTINATION"
ONLY_NULL_FIELDS ONLY_VALUED_FIELDS "DESTINATION"
ALL_FIELDS ONLY_NULL_FIELDS null
ONLY_VALUED_FIELDS ONLY_NULL_FIELDS null
ONLY_NULL_FIELDS ONLY_NULL_FIELDS "DESTINATION"

Examples

To better understand its use see the enumeration usage page.

Clone this wiki locally