[
https://issues.apache.org/jira/browse/COLLECTIONS-461?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13656484#comment-13656484
]
Thomas Neidhart commented on COLLECTIONS-461:
---------------------------------------------
I just tried it out myself, and it seems to work as expected:
{noformat}
Map<Integer, String> map = new HashMap<Integer, String>();
TransformedMap<Integer, Integer, String, String> mp =
TransformedMap.transformingMap(map,
new Transformer<Integer, Integer>() {
public Integer transform(Integer input) {
return input + 1;
}
}, new Transformer<String, String>() {
public String transform(String input) {
return "value:" + input;
}
});
String old = mp.put(1, "1");
System.out.println(old);
Put<Integer, String> put = mp;
System.out.println(put);
{noformat}
> 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