public Object put()

in base/src/main/java/org/apache/commons/chain2/impl/ContextBase.java [296:329]


    public Object put(String key, Object value) {
        /*
         * ConcurrentHashMap doesn't accept null values, see
         * http://download.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/ConcurrentHashMap.html#put(String, Object)
         */
        if (value == null) {
            if (containsKey(key)) {
                remove(key);
            }

            return null;
        }

        // Case 1 -- no local properties
        if (descriptors == null) {
            return super.put(key, value);
        }

        // Case 2 -- this is a local property
        if (key != null) {
            PropertyDescriptor descriptor = descriptors.get(key);
            if (descriptor != null) {
                Object previous = null;
                if (descriptor.getReadMethod() != null) {
                    previous = readProperty(descriptor);
                }
                writeProperty(descriptor, value);
                return previous;
            }
        }

        // Case 3 -- store or replace value in our underlying map
        return super.put(key, value);
    }