Uploaded image for project: 'Commons Chain'
  1. Commons Chain
  2. CHAIN-56

clever Context with generic type "auto-cast" feature

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0
    • Component/s: None
    • Labels:
      None

      Description

      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:

         /** @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.

        Attachments

          Activity

            People

            • Assignee:
              simone.tripodi Simone Tripodi
              Reporter:
              simone.tripodi Simone Tripodi
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: