I think the version using the Proxy pattern that you posted a few minutes ago is just as flexible and much easier to understand...just my $.02 :-)
-- 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 5:47 PM > To: Jakarta Commons Developers List > Subject: Re: [Collections][SUBMIT] TypedList > > > OK, this is a different design to one using Predicate, > although obviously a similar purpose. Before I can continue > and finish the other collections, I would like a decision on > which way to go ;-) > > This design gives much more power, but is therefore more > complex (more methods, more choice). Maybe there is a case > for both. Maybe there is a case for wrapping a Predicate in a > CollectionFilter. Not quite sure yet. > > I would suggest the following interface is necessary to fully > express the > possibilities: > public interface CollectionFilter { > // predicate > public boolean allowUpdate(Object obj, Collection coll); > // transform > public Object beforeUpdate(Object obj, Collection coll); > // info > public void afterUpdate(Object obj, Collection coll); > > // predicate > public boolean allowGet(Object obj, Collection coll); > // info ??? > public void beforeGet(Object obj, Collection coll); > // transform > public Object afterGet(Object obj, Collection coll); > > // predicate > public boolean allowRemove(Object obj, Collection coll); > // ??? > public Object beforeRemove(Object obj, Collection coll); > // ??? > public Object afterRemove(Object obj, Collection coll); > } > > Hmm. Having sketched that out, I think I'm tending towards > keeping it simple and sticking with PredicateList and > TransformList. Views? I need guidance on this one before I > can continue. > > Stephen > > From: Henri Yandell <[EMAIL PROTECTED]> > > public interface CollectionFilter { > > > > public Object beforeAdd(Object obj, Collection coll); > > > > public Object beforeRemove(Object obj, Collection coll); > > public Object afterRemove(Object obj, Collection coll); > > > > } > > > > > > And same (ish) for Map? And then List/Set extend Collection > filter and > > add events? > > > > When something is added to the collection, it checks with > beforeAdd, > > passing the object and the collection. In TypedFilter it is set to > > only allow Strings. It finds out the object isn't a String > and returns > > null? > > > > But does that mean return or insert null. Can we have an interface > > that means both Predicate and Transform?? Or should they be > separate. > > > > Hen > > > > > 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 -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>