Ted Husted wrote:

Craig R. McClanahan wrote:

 - If a user attempts to remove() the key corresponding to a property,
   throw IllegalArgumentException.


Can we make this an optional behavior?

Only if we make attribute-property transparency optional. That's what the contract for org.apache.commons.chain.Context still says right now, but I'm currently believing that this is needlessly complicated. If we want to keep it, though, we'll probably want two base classes -- one without transparency and a second one (built on top) with transparency, rather than a switchable behavior. There are ***lots*** more transparency issues than just this one.



The contact for Map.get and Map.remove says that they will return null if the entry is not present or if the value is null. This implies an alternate way to fulfill the Map.remove contract would be to set a local property to null.

The contract also says you can do things like unmodifiable Maps, in which case you're supposed to return UnsupportedOperationException.




        // Case 2 -- this is a local property
        if (key != null) {
+            if (removeLocal) {
+               return put(key,null);
+            }
+            } else {
                PropertyDescriptor descriptor =
                    (PropertyDescriptor) descriptors.get(key);

I'd like to apply this and add constructors that can be used to set "removeLocal". The default could be false, which provices the original behavior, and throws the exception.

I do have a use-case for this involving a working component that does try to use remove.

IMHO, part of our API contract for BaseContext should be that the local properties can be made transparent to a caller of the Map, and that a context should be able to use entries or fields with zero-changes to callers.

As above, if we're going to have two supported behaviors, I'd rather do it with two base classes. My preference would be that we don't make it optional, though, on the following grounds:


* It's simpler to just explain one behavior, than two.

* If you turn off transparency, why does Context exist
 at all?  Why not just use a Map directly?



-Ted.

Craig




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



Reply via email to