Class RuleSetCache

  • All Implemented Interfaces:
    java.io.Serializable

    public final class RuleSetCache
    extends java.lang.Object
    implements java.io.Serializable
    Simple in-memory LRU cache implementation.
    Since:
    2.1
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int cacheSize
      The fixed cache size.
      private int capacity
      The fixed cache capacity.
      private java.util.Map<java.lang.Class<?>,​FromAnnotationsRuleSet> data
      The map that implements the LRU cache.
      private float loadFactor
      The fixed cache load facor.
      private static long serialVersionUID
      This class serialVersionUID.
    • Constructor Summary

      Constructors 
      Constructor Description
      RuleSetCache()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static void checkKey​(java.lang.Class<?> key)
      Verify that a key is not null.
      boolean containsKey​(java.lang.Class<?> key)
      Returns true if this cache contains a mapping for the specified key.
      FromAnnotationsRuleSet get​(java.lang.Class<?> key)
      Returns the value to which the specified key is cached, or null if this cache contains no mapping for the key.
      void put​(java.lang.Class<?> key, FromAnnotationsRuleSet value)
      Associates the specified value with the specified key in this cache.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        This class serialVersionUID.
        See Also:
        Constant Field Values
      • capacity

        private final int capacity
        The fixed cache capacity.
      • data

        private final java.util.Map<java.lang.Class<?>,​FromAnnotationsRuleSet> data
        The map that implements the LRU cache.
    • Constructor Detail

      • RuleSetCache

        public RuleSetCache()
    • Method Detail

      • containsKey

        public boolean containsKey​(java.lang.Class<?> key)
        Returns true if this cache contains a mapping for the specified key.
        Parameters:
        key - key whose presence in this map is to be tested.
        Returns:
        true if this map contains a mapping for the specified key, false otherwise.
      • get

        public FromAnnotationsRuleSet get​(java.lang.Class<?> key)
        Returns the value to which the specified key is cached, or null if this cache contains no mapping for the key. Key parameter must not be null.
        Parameters:
        key - the key has to be checked it is present, it must not be null.
        Returns:
        the value to which the specified key is cached, null if this cache contains no mapping for the key.
      • put

        public void put​(java.lang.Class<?> key,
                        FromAnnotationsRuleSet value)
        Associates the specified value with the specified key in this cache. Key parameter must not be null.
        Parameters:
        key - key with which the specified value is to be associated.
        value - value to be associated with the specified key.
      • checkKey

        private static void checkKey​(java.lang.Class<?> key)
        Verify that a key is not null.
        Type Parameters:
        T - the generic key type.
        Parameters:
        key - the key object.