Class GenericMapCacheDelegate<K,​V>

java.lang.Object
io.github.xanthic.cache.core.delegate.GenericMapCacheDelegate<K,​V>
Type Parameters:
K - The type of keys that form the cache
V - The type of values contained in the cache
All Implemented Interfaces:
io.github.xanthic.cache.api.Cache<K,​V>

public class GenericMapCacheDelegate<K,​V>
extends java.lang.Object
implements io.github.xanthic.cache.api.Cache<K,​V>
Delegates cache calls to a Map view that already conforms to a desired ICacheSpec.

This class should only be used when implementing a CacheProvider, which yields a Map view.

  • Constructor Summary

    Constructors 
    Constructor Description
    GenericMapCacheDelegate​(java.util.Map<K,​V> map)  
  • Method Summary

    Modifier and Type Method Description
    protected boolean canEqual​(java.lang.Object other)  
    void clear()  
    V compute​(K key, @NotNull java.util.function.BiFunction<? super K,​? super V,​? extends V> computeFunc)  
    V computeIfAbsent​(K key, @NotNull java.util.function.Function<K,​V> computeFunc)  
    V computeIfPresent​(K key, @NotNull java.util.function.BiFunction<? super K,​? super V,​? extends V> computeFunc)  
    boolean equals​(java.lang.Object o)  
    V get​(K key)  
    java.util.Map<K,​V> getMap()  
    int hashCode()  
    V merge​(K key, V value, @NotNull java.util.function.BiFunction<V,​V,​V> mergeFunc)  
    V put​(K key, V value)  
    void putAll​(@NotNull java.util.Map<? extends K,​? extends V> map)  
    V putIfAbsent​(K key, V value)  
    V remove​(K key)  
    boolean replace​(K key, V value)  
    boolean replace​(K key, V oldValue, V newValue)  
    long size()  
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

  • Method Details

    • get

      public V get​(@NotNull K key)
      Specified by:
      get in interface io.github.xanthic.cache.api.Cache<K,​V>
    • put

      public V put​(@NotNull K key, @NotNull V value)
      Specified by:
      put in interface io.github.xanthic.cache.api.Cache<K,​V>
    • compute

      @Nullable public V compute​(@NotNull K key, @NotNull @NotNull java.util.function.BiFunction<? super K,​? super V,​? extends V> computeFunc)
      Specified by:
      compute in interface io.github.xanthic.cache.api.Cache<K,​V>
    • computeIfAbsent

      public V computeIfAbsent​(@NotNull K key, @NotNull @NotNull java.util.function.Function<K,​V> computeFunc)
      Specified by:
      computeIfAbsent in interface io.github.xanthic.cache.api.Cache<K,​V>
    • computeIfPresent

      public V computeIfPresent​(@NotNull K key, @NotNull @NotNull java.util.function.BiFunction<? super K,​? super V,​? extends V> computeFunc)
      Specified by:
      computeIfPresent in interface io.github.xanthic.cache.api.Cache<K,​V>
    • remove

      public V remove​(@NotNull K key)
      Specified by:
      remove in interface io.github.xanthic.cache.api.Cache<K,​V>
    • clear

      public void clear()
      Specified by:
      clear in interface io.github.xanthic.cache.api.Cache<K,​V>
    • size

      public long size()
      Specified by:
      size in interface io.github.xanthic.cache.api.Cache<K,​V>
    • putIfAbsent

      public V putIfAbsent​(@NotNull K key, @NotNull V value)
      Specified by:
      putIfAbsent in interface io.github.xanthic.cache.api.Cache<K,​V>
    • merge

      public V merge​(@NotNull K key, @NotNull V value, @NotNull @NotNull java.util.function.BiFunction<V,​V,​V> mergeFunc)
      Specified by:
      merge in interface io.github.xanthic.cache.api.Cache<K,​V>
    • replace

      public boolean replace​(@NotNull K key, @NotNull V value)
      Specified by:
      replace in interface io.github.xanthic.cache.api.Cache<K,​V>
    • replace

      public boolean replace​(@NotNull K key, @NotNull V oldValue, @NotNull V newValue)
      Specified by:
      replace in interface io.github.xanthic.cache.api.Cache<K,​V>
    • putAll

      public void putAll​(@NotNull @NotNull java.util.Map<? extends K,​? extends V> map)
      Specified by:
      putAll in interface io.github.xanthic.cache.api.Cache<K,​V>
    • getMap

      public java.util.Map<K,​V> getMap()
    • equals

      public boolean equals​(java.lang.Object o)
      Overrides:
      equals in class java.lang.Object
    • canEqual

      protected boolean canEqual​(java.lang.Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object