commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simone Tripodi (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CHAIN-56) clever Context with generic type "auto-cast" feature
Date Sun, 04 Sep 2011 16:43:14 GMT

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

Simone Tripodi commented on CHAIN-56:
-------------------------------------

the proposed {{store}} method is useless, since {{Context}} already inherits from {{Map<String,Object>}}
where {{put(String,Object)}} already perform the same feature.
OTOH, {{retrieve(String)}} does the magic.

> clever Context with generic type "auto-cast" feature
> ----------------------------------------------------
>
>                 Key: CHAIN-56
>                 URL: https://issues.apache.org/jira/browse/CHAIN-56
>             Project: Commons Chain
>          Issue Type: Improvement
>    Affects Versions: 2.0
>            Reporter: Simone Tripodi
>            Assignee: Simone Tripodi
>             Fix For: 2.0
>
>
> Generics could help us on improving the Context class; since it is clear that Context
is a place where storing/retrieving objects identified by a key, I propose adding two helper
methods:
> {code}
>    /** @since 2.0 */
>    <T> T retrieve( String key );
>    /** @since 2.0 */
>    <T> void store( String key, T object );
> {code}
> that would help users avoid the redundant code of type cast/checking when assignments
are already known (it throws a {{ClassCastException}} if types are not assignable). At the
same time, old pattern is supported, users can choose their
> preferred way to go, depending on their needs.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message