Class PropertyMapping
java.lang.Object
com.broadleafcommerce.metadata.dsl.core.Mapping<PropertyMapping>
com.broadleafcommerce.metadata.dsl.core.extension.mappings.PropertyMapping
- All Implemented Interfaces:
Copyable<PropertyMapping>
,Serializable
An implementation of
Mapping
for mapping a source value to its destination.- Author:
- Nick Crum (ncrum)
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
copy()
copyFrom
(boolean copyFrom) Copies the source property and maps to the destination property.Copies the source property and maps to the destination property.defaultValue
(Object defaultValue) boolean
getFrom()
The name of the property to renameThe type of operation applied when mapping the property.getTo()
The new name of the property.getValue()
The new value of the property with nameto
This is ignored iffrom
is definedint
hashCode()
boolean
isCopy()
Whether or not the property is copied.Maps the source's property to the destination's property.Maps the source's property to the destination's property with a default value.Maps theROOT
to the destination.mapValueToRoot
(String from) Maps the source's property to theROOT
.mergeTo()
Sets the destination property to null.Sets the value on the destination.
-
Field Details
-
ROOT
Reference to the "root" object being mapped.- See Also:
-
-
Constructor Details
-
PropertyMapping
public PropertyMapping() -
PropertyMapping
-
-
Method Details
-
copy
- Specified by:
copy
in interfaceCopyable<PropertyMapping>
- Returns:
- a deep copy of this instance
-
from
-
to
-
defaultValue
-
operation
-
replaceTo
-
mergeTo
-
copyFrom
-
mapValue
Maps the source's property to the destination's property. Useful for mapping a property, for example:// mapValue("state", "region"); { state: "TX" } => { region: "TX" }
- Parameters:
from
- the source propertyto
- the destination property- Returns:
- the mapping
-
mapValue
Maps the source's property to the destination's property with a default value. Useful for when you need a useful default, for example:// mapValue("state", "region", "N/A"); { city: "Washington" } => { city: "Washington", region: "N/A" }
- Parameters:
from
- the source propertyto
- the destination propertydefaultValue
- the default value- Returns:
- the mapping
-
mapValueToRoot
Maps the source's property to theROOT
. Useful for reducing an object down to one of its properties, for example:// mapValueToRoot("label") { label: "RED" } => "RED"
- Parameters:
from
- the source property- Returns:
- the mapping
-
mapValueFromRoot
Maps theROOT
to the destination. Useful for mapping an object to a property of a new object.// mapValueFromRoot("details") { label: "RED" } => { details: { label: "RED" } }
- Parameters:
to
- the destination property- Returns:
- the mapping
-
setValue
Sets the value on the destination. Useful for defaulting the value of a property, for example:// setValue("state", "TX"); { city: "Austin" } => { city: "Austin", state: "TX" }
- Parameters:
to
- the destination propertydefaultValue
- the default value of the property- Returns:
- the mapping
-
nullValue
Sets the destination property to null. Useful for clearing out a value, for example:// nullValue("state"); { state: "TX" } => { state: null }
- Parameters:
to
- the destination property- Returns:
- the mapping
-
copyValue
Copies the source property and maps to the destination property. Useful for mapping a property while preserving the original value, for example:// copyValue("state", "region"); { state: "TX" } => { state: "TX", region: "TX" }
- Parameters:
from
- the source propertyto
- the destination property- Returns:
- the mapping
-
copyValue
Copies the source property and maps to the destination property. Useful for when you need a useful default, for example:// copyValue("state", "region", "TX"); { } => { region: "TX" }
- Parameters:
from
- the source propertyto
- the destination propertydefaultValue
- the default value- Returns:
- the mapping
-
getFrom
The name of the property to rename -
getTo
The new name of the property. This can not be null or empty If this is equals toROOT
then all properties fromfrom
will be mapped to the root object. -
getOperation
The type of operation applied when mapping the property. -
getValue
The new value of the property with nameto
This is ignored iffrom
is defined -
isCopy
public boolean isCopy()Whether or not the property is copied. If false, the original property will be omitted. -
equals
- Overrides:
equals
in classMapping<PropertyMapping>
-
canEqual
- Overrides:
canEqual
in classMapping<PropertyMapping>
-
hashCode
public int hashCode()- Overrides:
hashCode
in classMapping<PropertyMapping>
-