Implementing path based transformer

2 views
Skip to first unread message

maxmil

unread,
Oct 5, 2010, 3:49:59 PM10/5/10
to beanlib
I would like to exclude a specif path in my object graph.

Say i have this situation:

Class A contains
- Class B contains
- Class C
- Class C

I want to include the instance of Class C that belongs to A but not
that that belongs to B.

The only way to do this i can see is with a property vetoer by
checking the owning class of the reader method.

However i would like some way to specify arbitrary paths for inclusion/
exclusion. Like A > B > A > C and not A > C where the last two classes
in the chain are the same.

Can anyone enlighten me on whether i can do this currently with
beanlib? Would a custom transformer be "aware" of where it is in the
object graph?

Thanks

Hanson Char

unread,
Oct 5, 2010, 6:28:16 PM10/5/10
to bea...@googlegroups.com
> Would a custom transformer be "aware" of where it is in the object graph?

Not the ful location/path in the object graph, but the
CustomBeanTransformerSpi would provide information of both the
immediate object from which a property is being
replicated/transformed, and the target class.

So it should work in your example, since the C instance can be
differentiated by whether it is a property of A vs B.

maxmil

unread,
Oct 6, 2010, 4:10:07 AM10/6/10
to beanlib
But i would not be able to differentiate A > B > A > C and A > C.

Thanks anyway.

Hanson Char

unread,
Oct 6, 2010, 11:06:09 AM10/6/10
to bea...@googlegroups.com
No you won't. It's possible to maintain the call paths (which is
currently implicit in the call stack), but that would be expensive.
Reply all
Reply to author
Forward
0 new messages