You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "Lazarte, Ivan" <iv...@away.com> on 2006/04/28 17:40:42 UTC

[collections] ReversePredicate

I didn't see a reverse predicate object in the 3.1 api, so I wrote one
quickly.  Enjoy!

 

package your.package.goes.here.dude;

 

import org.apache.commons.collections.Predicate;

 

/**

 * Take a predicate as a value and reverse the sign.

 */

 

public class ReversePredicate implements Predicate {

 

            Predicate predicate;

            

            public ReversePredicate(Predicate predicate) {

                        this.predicate = predicate;

            }

 

            public boolean evaluate(Object object) {

                        return (predicate.evaluate(object) == true) ?
false : true;

            }

}

 

Ivan Lazarte
Web Application Developer
The Away Network
(p) 202.654.8046
(f)  202.654.8081
1001 G St. NW
Suite 725W
Washington, DC 20001
| Away.com | Outside Online | GORP.com |

 


Re: [collections] ReversePredicate

Posted by Stephen Colebourne <sc...@btopenworld.com>.
This looks like NotPredicate to me ;-)

Stephen


Lazarte, Ivan wrote:
> I didn't see a reverse predicate object in the 3.1 api, so I wrote one
> quickly.  Enjoy!
> 
>  
> 
> package your.package.goes.here.dude;
> 
>  
> 
> import org.apache.commons.collections.Predicate;
> 
>  
> 
> /**
> 
>  * Take a predicate as a value and reverse the sign.
> 
>  */
> 
>  
> 
> public class ReversePredicate implements Predicate {
> 
>  
> 
>             Predicate predicate;
> 
>             
> 
>             public ReversePredicate(Predicate predicate) {
> 
>                         this.predicate = predicate;
> 
>             }
> 
>  
> 
>             public boolean evaluate(Object object) {
> 
>                         return (predicate.evaluate(object) == true) ?
> false : true;
> 
>             }
> 
> }
> 
>  
> 
> Ivan Lazarte
> Web Application Developer
> The Away Network
> (p) 202.654.8046
> (f)  202.654.8081
> 1001 G St. NW
> Suite 725W
> Washington, DC 20001
> | Away.com | Outside Online | GORP.com |
> 
>  
> 
> 

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