commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@btopenworld.com
Subject Re: [reflect][collection] Predicate - a question
Date Mon, 17 Jun 2002 12:20:37 GMT
>  from:    Ola Berg <ola.berg@arkitema.se>

This seems like a reasonable decorator to me. In collections at present, the decorators for
Predicate are on PredicateUtils. Included are And, Or, Not, InstanceOf, Null, NotNull. This
would be another one to add.

Stephen

> I agree with you. And I would like to elaborate, by letting Assert become a decorator
for Predicate:
> 
> /**
> This class throws AssertionException if the underlying
> Predicate evaluates to false.
> */
> class AssertingPredicate implements Predicate {
> 
>     private Predicate _predicate;
> 
>     public AssertingPredicate( Predicate predicate){
>         _predicate = predicate;
>     }
> 
>     public boolean evaluate( Object input){
>         if (!_predicate.evaluate( input)){
>             throw new AssertionException( input, predicate);
>         }
>         else{
>             return true;
>         }
>     }
> }
> 
> Could be a candidate for lang (where Predicate already should be IMO). Are common assertion
mechanisms discussed here before?
> 
> /O
> 
> --
> To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>
> 


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


Mime
View raw message