Class InMemoryCache<K,​V>

  • Type Parameters:
    K - The type of the key.
    V - The type of the value.
    All Implemented Interfaces:
    com.github.javaparser.resolution.cache.Cache<K,​V>

    public class InMemoryCache<K,​V>
    extends java.lang.Object
    implements com.github.javaparser.resolution.cache.Cache<K,​V>
    A cache implementation that stores the information in memory.
    The current implementation stores the values in memory in a WeakHashMap.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean contains​(K key)  
      static <expectedK,​expectedV>
      InMemoryCache<expectedK,​expectedV>
      create()
      Create a new instance for a cache in memory.
      java.util.Optional<V> get​(K key)  
      boolean isEmpty()  
      void put​(K key, V value)  
      void remove​(K key)  
      void removeAll()  
      long size()  
      com.github.javaparser.resolution.cache.CacheStats stats()  
      • Methods inherited from class java.lang.Object

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

      • create

        public static <expectedK,​expectedV> InMemoryCache<expectedK,​expectedV> create()
        Create a new instance for a cache in memory.
        Type Parameters:
        expectedK - The expected type for the key.
        expectedV - The expected type for the value.
        Returns:
        A newly created instance of InMemoryCache.
      • put

        public void put​(K key,
                        V value)
        Specified by:
        put in interface com.github.javaparser.resolution.cache.Cache<K,​V>
      • get

        public java.util.Optional<V> get​(K key)
        Specified by:
        get in interface com.github.javaparser.resolution.cache.Cache<K,​V>
      • remove

        public void remove​(K key)
        Specified by:
        remove in interface com.github.javaparser.resolution.cache.Cache<K,​V>
      • removeAll

        public void removeAll()
        Specified by:
        removeAll in interface com.github.javaparser.resolution.cache.Cache<K,​V>
      • contains

        public boolean contains​(K key)
        Specified by:
        contains in interface com.github.javaparser.resolution.cache.Cache<K,​V>
      • size

        public long size()
        Specified by:
        size in interface com.github.javaparser.resolution.cache.Cache<K,​V>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface com.github.javaparser.resolution.cache.Cache<K,​V>
      • stats

        public com.github.javaparser.resolution.cache.CacheStats stats()
        Specified by:
        stats in interface com.github.javaparser.resolution.cache.Cache<K,​V>