commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ola Berg <ola.b...@arkitema.se>
Subject Re: [reflect][collection] Predicate - a question
Date Mon, 17 Jun 2002 12:10:08 GMT
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>


Mime
View raw message