Well I think all you need is a TypeCheckPredicate class...real simple:

    public class TypeCheckPredicate implements Predicate {
      private Class type;

      public TypeCheckPredicate(Class type) {
        this.type = type;
      }

      public boolean evaluate(Object input) {
        return type.isInstance(input);
      }
    }

PredicatedList would just take a Predicate in its constructor, and
anytime someone adds an element it throws an exception if the
predicate's evalute method returns false on the element.  Then when
TypedList extends PredicatedList it becomes a very small class that
simply constructs a TypeCheckPredicate and passes it to its superclass.
-- 
Tim Moore / Blackboard Inc. / Software Engineer
1899 L Street, NW / 5th Floor / Washington, DC 20036
Phone 202-463-4860 ext. 258 / Fax 202-463-4863


> -----Original Message-----
> From: Stephen Colebourne [mailto:[EMAIL PROTECTED]] 
> Sent: Tuesday, April 23, 2002 4:30 PM
> To: Jakarta Commons Developers List
> Subject: Re: [Collections][SUBMIT] TypedList
> 
> 
> From: Henri Yandell <[EMAIL PROTECTED]>
> > To answer myself, very bad form. I imagine that we would have a 
> > MapFilter/Predicate and a CollectionFilter/Predicate. Separate 
> > structures. Maybe allowing an adaptor for Maps which could use 
> > Collections on keys or values.
> 
> So we need something more than the existing 
> Predicate/Transformer classes then? I think I need to go and 
> code something to it working... Stephen
> 
> > Hen
> >
> > On Tue, 23 Apr 2002, Henri Yandell wrote:
> >
> > > or some such. I imagine the Predicate should have access 
> to the list 
> > > it came from, so it would have a setCollection setMap? interface?
> Something.
> > >
> > > public void setStructure(Object structure).
> > >
> > > Then I can have a predicate which says, let the first person in, 
> > > then
> let
> > > no one else in who has a birthday of <birthday>.
> > >
> > > I would also then imagine a MultiPredicate which takes a bunch of 
> > > Predicates and only allows things if each one works.
> > >
> > > *ponder* I'm starting to waffle.
> > >
> > > Hen
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > >
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> >
> >
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:commons-dev-> [EMAIL PROTECTED]>
> For 
> additional commands, 
> e-mail: <mailto:[EMAIL PROTECTED]>
> 
> 

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to