org.jdto.mergers
Class GroovyMerger
java.lang.Object
org.jdto.mergers.AbstractGroovyMerger
org.jdto.mergers.GroovyMerger
- All Implemented Interfaces:
- Serializable, PropertyValueMerger, SinglePropertyValueMerger<Object,Object>
public class GroovyMerger
- extends AbstractGroovyMerger
- implements SinglePropertyValueMerger<Object,Object>
Merge the source value by evaluating a Groovy Expression.
This merger uses the embedded Groovy engine to provide convenience and
simplicity to specify complex transformations.
In order to access the input of this merger, a scoped variable called
sourceValue has been introduced.
For convenience, the following packages have been imported:
- org.apache.commons.lang.*
- java.util.*
- java.math.*
Finally, a scoped variable called logger has been introduced to help
with logging.
Here are some examples:
"sourceValue.toString()" //convert to string.
"sourceValue == null ? 'isNull' : 'isNotNull'" //check for nulls
"StringUtils.reverse(sourceValue)" //Access the StringUtils class from commons.
"logger.error('Value is: ' + sourceValue); return sourceValue;" //log the value and return it.
- Author:
- Juan Alberto López Cavallotti
- See Also:
- Serialized Form
|
Method Summary |
Object |
mergeObjects(Object value,
String[] extraParam)
Merge the source value by applying the groovy expression sent as the first
merger parameter. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
GroovyMerger
public GroovyMerger()
mergeObjects
public Object mergeObjects(Object value,
String[] extraParam)
- Merge the source value by applying the groovy expression sent as the first
merger parameter.
- Specified by:
mergeObjects in interface SinglePropertyValueMerger<Object,Object>
- Parameters:
value - the object to be merged.extraParam - the first element is the groovy expression to evaluate.
- Returns:
- the result of evaluating the expression.
Copyright © 2012. All Rights Reserved.