You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by James Carman <ja...@carmanconsulting.com> on 2006/02/07 17:20:38 UTC
[collections] Element of Predicate?
I couldn't find it, but do we have an ElementOfPredicate somewhere.
Basically, it'd return true if the object is an element of a collection
that's passed into the constructor?
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [collections] Element of Predicate?
Posted by Stephen Colebourne <sc...@btopenworld.com>.
We don't have such a thing, but IMHO, nor can we until functor gets
properly broken out (due to jar size).
Stephen
James Carman wrote:
> To be more precise:
>
> public class ElementOfPredicate implements Predicate
> {
> private final Collection c;
>
> public ElementOfPredicate( Collection c )
> {
> this.c = c;
> }
>
> public boolean evaluate( Object o )
> {
> return c.contains( o );
> }
> }
>
> -----Original Message-----
> From: James Carman [mailto:james@carmanconsulting.com]
> Sent: Tuesday, February 07, 2006 11:21 AM
> To: 'Jakarta Commons Developers List'
> Subject: [collections] Element of Predicate?
>
> I couldn't find it, but do we have an ElementOfPredicate somewhere.
> Basically, it'd return true if the object is an element of a collection
> that's passed into the constructor?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
RE: [collections] Element of Predicate?
Posted by James Carman <ja...@carmanconsulting.com>.
To be more precise:
public class ElementOfPredicate implements Predicate
{
private final Collection c;
public ElementOfPredicate( Collection c )
{
this.c = c;
}
public boolean evaluate( Object o )
{
return c.contains( o );
}
}
-----Original Message-----
From: James Carman [mailto:james@carmanconsulting.com]
Sent: Tuesday, February 07, 2006 11:21 AM
To: 'Jakarta Commons Developers List'
Subject: [collections] Element of Predicate?
I couldn't find it, but do we have an ElementOfPredicate somewhere.
Basically, it'd return true if the object is an element of a collection
that's passed into the constructor?
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org