Mapping Strategy

Mapping behavior for null values.

Use the mapping strategy to define basic mapping behavior for null values.

Options

The following options are available for mapping strategy:

  • MAP_ALL - A strategy that maps all values of a field.

  • MAP_NOT_NULL - A strategy that maps only the values of a field that are not null. If the field value is null it will not override the current value in the target class instance. This is the default strategy when creating a new ShapeShift instance.

Usage

There are two options for setting the mapping strategy:

Default Mapping Strategy

Settings the default mapping strategy for the ShapeShift instance.

val shapeShift = ShapeShiftBuilder()
    .withDefaultMappingStrategy(MappingStrategy.MAP_ALL)
    .build()

Override Mapping Strategy

Overriding the mapping strategy for a specific field.

Annotations

Kotlin DSL

Java Builder

Last updated

Was this helpful?