--- On Sat, 1/30/10, Adam Heath <[email protected]> wrote:
> From: Adam Heath <[email protected]>
> Subject: Re: svn commit: r904962 - in /ofbiz/trunk/framework: 
> base/src/org/ofbiz/base/util/collections/FlexibleMapAccessor.java 
> base/src/org/ofbiz/base/util/string/UelUtil.java 
> minilang/src/org/ofbiz/minilang/method/ContextAccessor.java
> To: [email protected]
> Cc: [email protected]
> Date: Saturday, January 30, 2010, 7:30 PM
> [email protected]
> wrote:
> > Author: adrianc
> > Date: Sun Jan 31 03:24:58 2010
> > New Revision: 904962
> > 
> > URL: http://svn.apache.org/viewvc?rev=904962&view=rev
> > Log:
> > Based on advice from Adam Heath, made
> FlexibleMapAccessor and UelUtil methods syntactically
> correct. Methods that read Maps take read-only Map
> arguments, and methods that write Maps take writable Map
> arguments.
> > 
> > 
> > Modified:
> > 
>    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/FlexibleMapAccessor.java
> > 
>    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelUtil.java
> > 
>    ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ContextAccessor.java
> > 
> > Modified:
> ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/FlexibleMapAccessor.java
> > URL: 
> > http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/FlexibleMapAccessor.java?rev=904962&r1=904961&r2=904962&view=diff
> >
> ==============================================================================
> > ---
> ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/FlexibleMapAccessor.java
> (original)
> > +++
> ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/FlexibleMapAccessor.java
> Sun Jan 31 03:24:58 2010
> > @@ -170,7 +170,7 @@
> >       * @param base the Map
> to remove from
> >       * @return the object
> removed
> >       */
> > -    public T remove(Map<String, ?
> extends Object> base) {
> > +    public T remove(Map<String,
> Object> base) {
> 
> Heh, not quite correct.  You are allowed to remove
> items from a map
> with ? extends.
> 
> If you recall, ? extends means that the exact class of the
> value is
> unknown.  Since you don't know what the concrete class
> is, it's not
> possible to store any new values into the map, as you might
> break the
> generics contract.
> 
> However, removing an item does not break the generics
> contract.  So,
> this change is not correct.

I did a partial revert and had FMA's remove method convert the read-only Map to 
a writable Map. The UEL spec doesn't include a "remove" function, so I have to 
simulate it by replacing the value with null.

This is as close as I can get to the ideal. If anyone else wants to take a stab 
at it, they are more than welcome.




Reply via email to