commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lazarte, Ivan" <i...@away.com>
Subject [collections] ReversePredicate
Date Fri, 28 Apr 2006 15:40:42 GMT
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 |

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message