org.jcon.data
Class PropertyScrambler

java.lang.Object
  extended by org.jcon.data.PropertyScrambler
All Implemented Interfaces:
ObjectTransform

public class PropertyScrambler
extends java.lang.Object
implements ObjectTransform

Lets you rename and duplicate BeanGraph properties. An ObjectTransform that, configured with a mapping of old property names onto new ones, transforms BeanGraphable objects into Maps with the new property names.

An example. Suppose you had an input object with a property name "hue", that you want to pass to something that requires a property named "color". If you created a PropertyScrambler with the propertyMapping set to {"color" = "hue"} you'd be all set.

Another example. Suppose you (in a report or something) need two copies of an object. Then you could use a propertyMapping {"copy1" = ".", "copy2" = "."} and be ready to go.

Additionally, if you provide a list of property paths instead of a single path, it will choose the value of the first property in the list that is nontrivial - i.e., neither null nor blank.

Author:
Paul Reavis

Constructor Summary
PropertyScrambler()
           
PropertyScrambler(java.util.Map propertyMapping)
           
 
Method Summary
 java.util.Map getPropertyMapping()
           
 boolean isPassingThrough()
          If true, also passes through unlisted properties unchanged (unless their names have been overridden by the mapping).
 void setPassingThrough(boolean tizit)
           
 void setPropertyMapping(java.util.Map newMapping)
           
 java.lang.Object transform(java.lang.Object victim)
          Our one method; this transforms one object into another.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyScrambler

public PropertyScrambler()

PropertyScrambler

public PropertyScrambler(java.util.Map propertyMapping)
Method Detail

transform

public java.lang.Object transform(java.lang.Object victim)
Description copied from interface: ObjectTransform
Our one method; this transforms one object into another. Transformation must be nondestructive, but may produce a derived product that is still affected by changes to the original, so beware.

Specified by:
transform in interface ObjectTransform

getPropertyMapping

public java.util.Map getPropertyMapping()

setPropertyMapping

public void setPropertyMapping(java.util.Map newMapping)

isPassingThrough

public boolean isPassingThrough()
If true, also passes through unlisted properties unchanged (unless their names have been overridden by the mapping).


setPassingThrough

public void setPassingThrough(boolean tizit)