[ 
https://issues.apache.org/jira/browse/COLLECTIONS-461?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13656508#comment-13656508
 ] 

Matt Benson commented on COLLECTIONS-461:
-----------------------------------------

Riight... I hadn't looked at this stuff in years.  {{TransformedMap}} narrows 
the RT from {{Object}} to return {{V}} from {{#put(J, U)}} and in that sense 
will never behave like a regular {{Map}}--my point being that we don't know how 
to "untransform" the value back to the {{U}} type.  Returning the value 
actually contained in the target map is the best we can do.  The proposed 
{{#putTransformed()}} method would still suffer the same problem:  no way to 
get back to a {{U}} type from the {{V}} contained in the decorated {{Map}}.  Is 
the issue that {{TransformedMap}} is still named \*Map?  It was my intent that 
placing it in the {{splitmap}} subpackage would, along with 
[http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/splitmap/package-info.java?view=markup],
 make the intent clear: namely, that a "split map" is like a "map" but is 
really a combination of {{Get}}/{{Put}} with no guarantees as to the type 
assignability between the two.  This was the only approach I found at the time 
to allow the preservation of the functionality of {{TransformedMap}} while also 
permitting it to be fully genericized.
                
> splitmap.TransformedMap is not really a Map
> -------------------------------------------
>
>                 Key: COLLECTIONS-461
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-461
>             Project: Commons Collections
>          Issue Type: Bug
>            Reporter: Sebb
>             Fix For: 4.x
>
>
> splitmap.TransformedMap is part of the Get/Put hierarchy, but it does not 
> behave like a proper Java Map. 
> In particular, java.util.Map.put(K, V) returns V.
> However the collections Put interface returns Object.
> As far as I can tell, this was done in order to be able to include 
> TransformedMap in the hiearchy. But the side effect is to break the generics 
> for all the non-transformer maps in the hierarchy.
> Maybe there should be a separate PutTransformed interface which has the 
> appropriate generic types, i.e.
> public T put(K key, V value)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to