commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rafael U\. C\. Afonso" <r.u.c.afo...@uol.com.br>
Subject Re: [collections] Can Closures return values?
Date Thu, 26 May 2005 14:26:20 GMT
Andy:

Commons Collections API is here: http://jakarta.apache.org/commons/collections/apidocs-COLLECTIONS_3_1/index.html
Based in your case, I think that you should use a InvokerTransformer (http://jakarta.apache.org/commons/collections/apidocs-COLLECTIONS_3_1/org/apache/commons/collections/functors/InvokerTransformer.html)
and a EqualPredicate (http://jakarta.apache.org/commons/collections/apidocs-COLLECTIONS_3_1/org/apache/commons/collections/functors/EqualPredicate.html).

Good luck,

Rafael Ubiratam Clemente Afonso
r.u.c.afonso@uol.com.br
---------------------------------
Where is Debug?
Debug is on the Table!

---------- Início da mensagem original -----------

      De: "Andy Kriger" andy.kriger@gmail.com
    Para: "Rafael U. C. Afonso" r.u.c.afonso@uol.com.br
      Cc: 
    Data: Thu, 26 May 2005 09:54:23 -0400
 Assunto: Re: [collections] Can Closures return values?

> Thx - I'm not that familiar with the collections API and wasn't aware
> of that. Is there documentation on the Closure/Transformer/Predicate
> aspect of the collections API?
> 
> On 5/25/05, Rafael U. C. Afonso <r.u.c.afonso@uol.com.br> wrote:
> > Hello:
> > 
> > Why don't you use a Transformer? It returns a Object.
> > 
> > Thanks,
> > 
> > Rafael U. C. Afonso
> > 
> > ---------- Início da mensagem original -----------
> > 
> >       De: "Andy Kriger" andy.kriger@gmail.com
> >     Para: commons-user@jakarta.apache.org
> >       Cc:
> >     Data: Wed, 25 May 2005 17:06:09 -0400
> >  Assunto: [collections] Can Closures return values?
> > 
> > > I have a loop common to several methods where the behavior of the loop
> > > depends on the boolean result of different method calls.
> > >
> > > ex)
> > >
> > > do {
> > >    if(x.equals(y)) do some stuff
> > > } while(test)
> > >
> > > do {
> > >    if(x.startsWith(y)) do some stuff
> > > } while(test)
> > >
> > > etc
> > >
> > > The looping and testing are a bit more complicated than that (e.g. big
> > > nested loop). I'd like to use an invokerClosure to handle the test so
> > > that I can have one common method that takes the Closure as an
> > > argument. However, I don't see a way to get a return value from a
> > > Closure. Is this possible? I could make the whole if/then block the
> > > Closure.execute but if possible I'd like to know if the Closure is
> > > able to return values.
> > >
> > > thx
> > > andy
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: commons-user-help@jakarta.apache.org
> > >
> > >
> > 
> > Rafael Ubiratam Clemente Afonso
> > r.u.c.afonso@uol.com.br
> > ---------------------------------
> > Where is Debug?
> > Debug is on the Table!
> > 
> > __________________________________________________________________________
> > UOL Fone: Fale com o Brasil e o Mundo com até 90% de economia.
> > http://www.uol.com.br/fone
> > 
> > 
> >
> 


 
__________________________________________________________________________
UOL Fone: Fale com o Brasil e o Mundo com até 90% de economia. 
http://www.uol.com.br/fone



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message