Class KeyHelper

  • All Implemented Interfaces:

    
    public final class KeyHelper<IMMUTABLE_KEY extends Object, MUTABLE_KEY extends Object>
    
                        

    Utility class for a situation when we need to frequently use an immutable key (e.g. for checking shared ConcurrentHashMap content). We want to avoid creating new key objects all the time if a number of possible different key states is low and a number of threads which do the operation is also not big.

    The general idea is to do the following:

    • Keep thread-local mutable key

    • Get a mutable key any time new immutable key is required

    • Modify mutable key within the current thread-local data

    • Keep a cache of mutable key -> immutable key

    • Query target immutable key by mutable key

    • Create new immutable key on the basis of the mutable key and store it if the cache doesn't have corresponding entry yet

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description