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] [Created] (CHAIN-56) clever Context with generic type "auto-cast" feature
Date Sun, 04 Sep 2011 16:40:09 GMT
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
             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