Yeah absolutely, those can be used in more ways than "wrapping"
another iterable and maybe another name would be appropriate, but your
transformer is just one special case for that. So whatever name we
pick there will be uses of it that wont fit well with the name.

I think it's nice to see you use such utilities and finding new ways
of doing so. Keep it up!


/ Mattias

2009/7/29 Mattias Ask <[email protected]>:
> I just wanted to share something I just realized...
>
> Today I've been looking at the Functors API in commons-collections to
> see how that is applicable to the Traverser API in Neo. The one thing
> I was missing in the Traverser API was Transformer. There are two
> Predicate-like interfaces in the StopEvaluator and ReturnEvaluator but
> I miss something like the Transformer interface. As I was playing
> around with this I realized (as maybe many of you have done) that
> there indeed is something Transformer-like in Neo, namely
> IterableWrapper (in neo-utils). Up until now I've only used this for
> things like this:
>
> public Iterable<Receiver> getRecieversOfDonations() {
>                Traverser traverser = ... //My traverser that returns 
> RecieverNodes
>
>                return new IterableWrapper<Receiver, Node>(traverser) {
>                       �...@override
>                        protected Receiver underlyingObjectToObject(Node 
> object) {
>                                return new ReceiverNode(object);
>                        }
>                };
>        }
>
> What I realized today is that this is more powerful than that, and
> that I can do whatever I want with it, for example:
>
> Iterable<SomeBean> iterable = new IterableWrapper<SomeBean,
> Node>(traverser){
>       �...@override
>        protected SomeBean underlyingObjectToObject(Node node) {
>                CreditNode creditNode = new CreditNode(node);
>                DateTime createdDateTime = creditNode.getCreatedDateTime();
>                Relationship someRelationship = creditNode
>                                .getSingleRelationship(...);
>                CreditNode someOtherCredit = new CreditNode(someRelationship
>                                .getStartNode());
>                AnotherNode anotherNode = new
> AnotherNode(someOtherCredit.traverse(...)
>                                .iterator().next());
>                return new SomeBean(
>                                createdDateTime, 
> someOtherCredit.getSomething(),
> anotherNode.getName(), creditNode.getSomething());
>        }
> };
>
> When used like this the name may be somewhat inaccurate
> (IterableTransformer?), but I think this is really powerful. What do
> you think?
>
> Best regards, Mattias Ask
> -------------------------------------------
> Jayway AB, +46 701 469284
> www.jayway.com
>
> Jayway is the founder of Öredev and Qi4J
> www.oredev.org
> www.qi4j.org
>
>
>
>
> _______________________________________________
> Neo mailing list
> [email protected]
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Mattias Persson, [[email protected]]
Neo Technology, www.neotechnology.com
_______________________________________________
Neo mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to