commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simone Tripodi <>
Subject [chain][v2] clever context
Date Sun, 04 Sep 2011 09:22:25 GMT
Hi all guys,
I think that generics could help us on improving the Context class;
I'm not particularly happy having it extending Map - it is needed
anyway for backward compatibility - but it is clear that Context is a
place where storing/retrieving objects identified by a key.
I propose adding two helper methods

    /** @since 2.0 */
    <T> T retrieve( String key );

    /** @since 2.0 */
    <T> void store( String key, T object );

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.
Many thanks in advance, all the best!

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message