Class BasicCache<K,​V>

  • All Implemented Interfaces:
    java.lang.Iterable<java.util.Map.Entry<K,​V>>, org.comroid.mutatio.ref.ReferenceMap<K,​V,​Cache.Reference<K,​V>>, org.comroid.mutatio.ref.ReferenceMap.Settable<K,​V,​Cache.Reference<K,​V>>, Cache<K,​V>
    Direct Known Subclasses:
    ProvidedCache

    public class BasicCache<K,​V>
    extends java.lang.Object
    implements Cache<K,​V>
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.comroid.mutatio.ref.ReferenceMap

        org.comroid.mutatio.ref.ReferenceMap.Settable<K extends java.lang.Object,​V extends java.lang.Object,​REF extends org.comroid.mutatio.ref.Reference.Settable<V>>
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean containsKey​(K key)  
      boolean containsValue​(V value)  
      @NotNull Cache.Reference<K,​V> getReference​(K key, boolean createIfAbsent)  
      @NotNull java.util.Iterator<java.util.Map.Entry<K,​V>> iterator()  
      boolean large()  
      org.comroid.mutatio.pipe.Pipe<?,​Cache.Reference<K,​V>> pipe​(java.util.function.Predicate<K> filter)  
      int size()  
      java.util.stream.Stream<Cache.Reference<K,​V>> stream​(java.util.function.Predicate<K> filter)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
      • Methods inherited from interface org.comroid.mutatio.ref.ReferenceMap

        get, getReference, requireNonNull, requireNonNull, wrap
      • Methods inherited from interface org.comroid.mutatio.ref.ReferenceMap.Settable

        compute, computeIfAbsent, computeIfPresent, set
    • Field Detail

      • DEFAULT_LARGE_THRESHOLD

        public static final int DEFAULT_LARGE_THRESHOLD
        See Also:
        Constant Field Values
    • Constructor Detail

      • BasicCache

        public BasicCache()
      • BasicCache

        public BasicCache​(int largeThreshold)
      • BasicCache

        protected BasicCache​(int largeThreshold,
                             java.util.Map<K,​Cache.Reference<K,​V>> map)
      • BasicCache

        protected BasicCache​(int largeThreshold,
                             java.util.Map<K,​Cache.Reference<K,​V>> map,
                             @Nullable
                             org.comroid.api.Provider.Now<V> emptyValueProvider)
    • Method Detail

      • toString

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

        @NotNull
        public @NotNull java.util.Iterator<java.util.Map.Entry<K,​V>> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<K>
      • containsKey

        public boolean containsKey​(K key)
        Specified by:
        containsKey in interface Cache<K,​V>
      • containsValue

        public boolean containsValue​(V value)
        Specified by:
        containsValue in interface Cache<K,​V>
      • large

        public boolean large()
        Specified by:
        large in interface Cache<K,​V>
      • size

        public int size()
        Specified by:
        size in interface Cache<K,​V>
      • stream

        public final java.util.stream.Stream<Cache.Reference<K,​V>> stream​(java.util.function.Predicate<K> filter)
        Specified by:
        stream in interface Cache<K,​V>
      • pipe

        public org.comroid.mutatio.pipe.Pipe<?,​Cache.Reference<K,​V>> pipe​(java.util.function.Predicate<K> filter)
        Specified by:
        pipe in interface Cache<K,​V>
      • getReference

        @NotNull
        public @NotNull Cache.Reference<K,​V> getReference​(K key,
                                                                boolean createIfAbsent)
        Specified by:
        getReference in interface Cache<K,​V>
        Specified by:
        getReference in interface org.comroid.mutatio.ref.ReferenceMap<K,​V,​Cache.Reference<K,​V>>