commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Juozas Baliuka <>
Subject Re: [reflect][collection] Predicate - a question
Date Mon, 17 Jun 2002 11:19:03 GMT

  if predicate is used as "filter" it must return false, if it doe's 
assertion it must throw Exception.

  And it is possible to have something like this to reuse "filters" for 
assertion :

  class Assert {

   Predicate p;
    Assert(Predicate p){
      this.p = p;

    void assertObject(Object obj) throws AssertSomethingFailed{
      if(!p.evalute(obj)) throw new AssertSomethingFailed();



Predicate is too abstract to be clear for all situations.

At 13:00 2002.06.17 +0200, Ola Berg wrote:
>Ola wrote:
> >>do you rather throw like ClassCastException or let the
> >>Predicate#evaluate() return false? I can see that different situations
> >>call for different \\\"assertion schemes\\\" in that matter, what\\\'s the
> >>regular view on this?
>Juozas answered:
> >I prefer subclass or some kind of \"decorator\" for typed collections like
> >\"class Properties extends Hashtable\" or \"new Attributes(map)\",
> >it is situations then \"runtime type\" is parameter and \"Predicate\" is 
> good
> >solution in this case and I think it must throw ClassCastException,
> >if \"runtime type\" is \"bad\".
>Well, that doesn\'t answer the question, it just moves the problem inside 
>the type-safe wrapper. I already have a subclass (MethodPredicate). What 
>behaviour would you like if your type-safe wrapper _still_ is fed with the 
>wrong type? Or rather: how do you assert its type-safety?
>(personally for MethodPredicate I prefer returning false).
>0733 - 99 99 17
>To unsubscribe, e-mail:   <>
>For additional commands, e-mail: <>

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message