You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Matt Benson <gu...@yahoo.com> on 2006/02/02 20:52:28 UTC

[collections] IfClosure

Is there any interest in adding:

public IfClosure(Predicate predicate, Closure
trueClosure) {
    this(predicate, trueClosure, NOPClosure.INSTANCE);
}

public static Closure getInstance(Predicate predicate,
Closure trueClosure) {
    return getInstance(predicate, trueClosure,
NOPClosure.INSTANCE);
}

+ ClosureUtils.ifClosure(Predicate, Closure
trueClosure);

?

This is for convenience only... (and saving on
Collection instances).  If this would be accepted I
will submit a patch.

Thanks,
Matt

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: [collections] IfClosure

Posted by Matt Benson <gu...@yahoo.com>.
Stephen: I have submitted a PR @

http://issues.apache.org/bugzilla/show_bug.cgi?id=38495

Thanks,
Matt

--- Matt Benson <gu...@yahoo.com> wrote:

> --- Stephen Colebourne <sc...@btopenworld.com>
> wrote:
> 
> > The IfClosure is meant to represent an if
> statement
> > in code, so it 
> > should support what is effectively an if without
> an
> > else.
> 
> Glad you agree!  ;)
> 
> > 
> > If you do this, it should include the associated
> > static method on 
> > IfClosure and ClosureUtils.
> > 
> 
> I went ahead and did all of the above earlier for
> fun.
>  I'll submit the patch tomorrow.  Don't forget a
> couple of cursory tests too.
> 
> Thanks,
> Matt
> 
> > Stephen
> > 
> > 
> > Matt Benson wrote:
> > > Is there any interest in adding:
> > > 
> > > public IfClosure(Predicate predicate, Closure
> > > trueClosure) {
> > >     this(predicate, trueClosure,
> > NOPClosure.INSTANCE);
> > > }
> > > 
> > > public static Closure getInstance(Predicate
> > predicate,
> > > Closure trueClosure) {
> > >     return getInstance(predicate, trueClosure,
> > > NOPClosure.INSTANCE);
> > > }
> > > 
> > > + ClosureUtils.ifClosure(Predicate, Closure
> > > trueClosure);
> > > 
> > > ?
> > > 
> > > This is for convenience only... (and saving on
> > > Collection instances).  If this would be
> accepted
> > I
> > > will submit a patch.
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> > commons-dev-help@jakarta.apache.org
> > 
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam
> protection around 
> http://mail.yahoo.com 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> commons-dev-help@jakarta.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: [collections] IfClosure

Posted by Matt Benson <gu...@yahoo.com>.
--- Stephen Colebourne <sc...@btopenworld.com>
wrote:

> The IfClosure is meant to represent an if statement
> in code, so it 
> should support what is effectively an if without an
> else.

Glad you agree!  ;)

> 
> If you do this, it should include the associated
> static method on 
> IfClosure and ClosureUtils.
> 

I went ahead and did all of the above earlier for fun.
 I'll submit the patch tomorrow.  Don't forget a
couple of cursory tests too.

Thanks,
Matt

> Stephen
> 
> 
> Matt Benson wrote:
> > Is there any interest in adding:
> > 
> > public IfClosure(Predicate predicate, Closure
> > trueClosure) {
> >     this(predicate, trueClosure,
> NOPClosure.INSTANCE);
> > }
> > 
> > public static Closure getInstance(Predicate
> predicate,
> > Closure trueClosure) {
> >     return getInstance(predicate, trueClosure,
> > NOPClosure.INSTANCE);
> > }
> > 
> > + ClosureUtils.ifClosure(Predicate, Closure
> > trueClosure);
> > 
> > ?
> > 
> > This is for convenience only... (and saving on
> > Collection instances).  If this would be accepted
> I
> > will submit a patch.
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> commons-dev-help@jakarta.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: [collections] IfClosure

Posted by Stephen Colebourne <sc...@btopenworld.com>.
The IfClosure is meant to represent an if statement in code, so it 
should support what is effectively an if without an else.

If you do this, it should include the associated static method on 
IfClosure and ClosureUtils.

Stephen


Matt Benson wrote:
> Is there any interest in adding:
> 
> public IfClosure(Predicate predicate, Closure
> trueClosure) {
>     this(predicate, trueClosure, NOPClosure.INSTANCE);
> }
> 
> public static Closure getInstance(Predicate predicate,
> Closure trueClosure) {
>     return getInstance(predicate, trueClosure,
> NOPClosure.INSTANCE);
> }
> 
> + ClosureUtils.ifClosure(Predicate, Closure
> trueClosure);
> 
> ?
> 
> This is for convenience only... (and saving on
> Collection instances).  If this would be accepted I
> will submit a patch.

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