public class PropertyMapping extends Mapping<PropertyMapping> implements Serializable
Mapping
for mapping a source value to its destination.Modifier and Type | Class and Description |
---|---|
static class |
PropertyMapping.DefaultOperations |
Modifier and Type | Field and Description |
---|---|
static String |
ROOT
Reference to the "root" object being mapped.
|
Constructor and Description |
---|
PropertyMapping() |
PropertyMapping(PropertyMapping mapping) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
canEqual(Object other) |
PropertyMapping |
copy() |
PropertyMapping |
copyFrom(boolean copyFrom) |
PropertyMapping |
copyValue(String from,
String to)
Copies the source property and maps to the destination property.
|
PropertyMapping |
copyValue(String from,
String to,
Object defaultValue)
Copies the source property and maps to the destination property.
|
PropertyMapping |
defaultValue(Object defaultValue) |
boolean |
equals(Object o) |
PropertyMapping |
from(String from) |
String |
getFrom()
The name of the property to rename
|
String |
getOperation()
The type of operation applied when mapping the property.
|
String |
getTo()
The new name of the property.
|
Object |
getValue()
|
int |
hashCode() |
boolean |
isCopy()
Whether or not the property is copied.
|
PropertyMapping |
mapValue(String from,
String to)
Maps the source's property to the destination's property.
|
PropertyMapping |
mapValue(String from,
String to,
Object defaultValue)
Maps the source's property to the destination's property with a default value.
|
PropertyMapping |
mapValueFromRoot(String to)
Maps the
ROOT to the destination. |
PropertyMapping |
mapValueToRoot(String from)
Maps the source's property to the
ROOT . |
PropertyMapping |
mergeTo() |
PropertyMapping |
nullValue(String to)
Sets the destination property to null.
|
PropertyMapping |
operation(String operation) |
PropertyMapping |
replaceTo() |
PropertyMapping |
setValue(String to,
Object defaultValue)
Sets the value on the destination.
|
PropertyMapping |
to(String to) |
public static final String ROOT
public PropertyMapping()
public PropertyMapping(PropertyMapping mapping)
public PropertyMapping copy()
copy
in interface Copyable<PropertyMapping>
public PropertyMapping from(@Nullable String from)
public PropertyMapping to(@Nullable String to)
public PropertyMapping defaultValue(@Nullable Object defaultValue)
public PropertyMapping operation(@Nullable String operation)
public PropertyMapping replaceTo()
public PropertyMapping mergeTo()
public PropertyMapping copyFrom(boolean copyFrom)
public PropertyMapping mapValue(String from, String to)
// mapValue("state", "region"); { state: "TX" } => { region: "TX" }
from
- the source propertyto
- the destination propertypublic PropertyMapping mapValue(String from, String to, @Nullable Object defaultValue)
// mapValue("state", "region", "N/A"); { city: "Washington" } => { city: "Washington", region: "N/A" }
from
- the source propertyto
- the destination propertydefaultValue
- the default valuepublic PropertyMapping mapValueToRoot(String from)
ROOT
. Useful for reducing an object down to one of
its properties, for example:
// mapValueToRoot("label") { label: "RED" } => "RED"
from
- the source propertypublic PropertyMapping mapValueFromRoot(String to)
ROOT
to the destination. Useful for mapping an object to a property of a
new object.
// mapValueFromRoot("details") { label: "RED" } => { details: { label: "RED" } }
to
- the destination propertypublic PropertyMapping setValue(String to, @Nullable Object defaultValue)
// setValue("state", "TX"); { city: "Austin" } => { city: "Austin", state: "TX" }
to
- the destination propertydefaultValue
- the default value of the propertypublic PropertyMapping nullValue(String to)
// nullValue("state"); { state: "TX" } => { state: null }
to
- the destination propertypublic PropertyMapping copyValue(String from, String to)
// copyValue("state", "region"); { state: "TX" } => { state: "TX", region: "TX" }
from
- the source propertyto
- the destination propertypublic PropertyMapping copyValue(String from, String to, @Nullable Object defaultValue)
// copyValue("state", "region", "TX"); { } => { region: "TX" }
from
- the source propertyto
- the destination propertydefaultValue
- the default valuepublic String getFrom()
public String getTo()
public String getOperation()
public Object getValue()
public boolean isCopy()
public boolean equals(Object o)
equals
in class Mapping<PropertyMapping>
protected boolean canEqual(Object other)
canEqual
in class Mapping<PropertyMapping>
public int hashCode()
hashCode
in class Mapping<PropertyMapping>
Copyright © 2021. All rights reserved.