Re: [Simple-support] Limiting CycleStrategy to affect only objects of a certain type
Brought to you by:
niallg
|
From: Stanislaw O. <sta...@ca...> - 2008-02-13 13:06:17
|
> Yes you can, I use a filter like pattern to do this.
> For example if you wrote the following.
>
> public class AttributeModifier implements Strategy {
>
> private Strategy strategy;
>
> public AttributeModifier(Strategy strategy) {
> this.strategy = strategy;
> }
>
> // remainder here...
>
> public boolean setElement(Class field, Object
> value, NodeMap node, Map map) throws Exception;
> boolean result = strategy.setElement(field,
> value, node, map);
> Node node = node.remove("id");
>
> if(MyClass.class.isInstance(value)) {
> node.put(node.getValue());
> }
> return result;
> }
> }
>
That does the trick, thanks!
Staszek
|