Class WriteableCacheCollectionMapper<E,​R>

  • Type Parameters:
    E - the original collection type - referred to as old in some methods
    R - the resulting collection type - referred to as new in some methods
    All Implemented Interfaces:
    java.lang.Iterable<R>, java.util.Collection<R>, CacheCollection<R>, CloseableIteratorCollection<R>
    Direct Known Subclasses:
    WriteableCacheSetMapper

    public class WriteableCacheCollectionMapper<E,​R>
    extends CollectionMapper<E,​R>
    implements CacheCollection<R>
    A writeable cache collection mapper that also has constant time operations for things such as Collection.contains(Object) if the underlying Collection does.

    This collection should be used for cases when a simple transformation of a element to another is all that is needed by the underlying collection.

    Note this class allows for a different function specifically for values returned from an iterator. This can be useful to intercept calls such as Map.Entry.setValue(Object) and update appropriately.

    Since:
    9.2
    Author:
    wburns
    • Field Detail

      • toNewTypeIteratorFunction

        protected final java.util.function.Function<? super E,​? extends R> toNewTypeIteratorFunction
      • fromNewTypeFunction

        protected final java.util.function.Function<? super R,​? extends E> fromNewTypeFunction
      • keyFilterMapper

        protected final InjectiveFunction<java.lang.Object,​?> keyFilterMapper
    • Constructor Detail

      • WriteableCacheCollectionMapper

        public WriteableCacheCollectionMapper​(CacheCollection<E> realCollection,
                                              java.util.function.Function<? super E,​? extends R> toNewTypeFunction,
                                              java.util.function.Function<? super R,​? extends E> fromNewTypeFunction,
                                              InjectiveFunction<java.lang.Object,​?> keyFilterFunction)
      • WriteableCacheCollectionMapper

        public WriteableCacheCollectionMapper​(CacheCollection<E> realCollection,
                                              java.util.function.Function<? super E,​? extends R> toNewTypeFunction,
                                              java.util.function.Function<? super E,​? extends R> toNewTypeIteratorFunction,
                                              java.util.function.Function<? super R,​? extends E> fromNewTypeFunction,
                                              InjectiveFunction<java.lang.Object,​?> keyFilterFunction)
    • Method Detail

      • contains

        public boolean contains​(java.lang.Object o)
        Specified by:
        contains in interface java.util.Collection<E>
        Overrides:
        contains in class java.util.AbstractCollection<R>
      • containsAll

        public boolean containsAll​(java.util.Collection<?> c)
        Specified by:
        containsAll in interface java.util.Collection<E>
        Overrides:
        containsAll in class java.util.AbstractCollection<R>
      • add

        public boolean add​(R e)
        Specified by:
        add in interface java.util.Collection<E>
        Overrides:
        add in class CollectionMapper<E,​R>
      • addAll

        public boolean addAll​(java.util.Collection<? extends R> c)
        Specified by:
        addAll in interface java.util.Collection<E>
        Overrides:
        addAll in class CollectionMapper<E,​R>
      • remove

        public boolean remove​(java.lang.Object o)
        Specified by:
        remove in interface java.util.Collection<E>
        Overrides:
        remove in class CollectionMapper<E,​R>
      • removeAll

        public boolean removeAll​(java.util.Collection<?> c)
        Specified by:
        removeAll in interface java.util.Collection<E>
        Overrides:
        removeAll in class CollectionMapper<E,​R>
      • retainAll

        public boolean retainAll​(java.util.Collection<?> c)
        Specified by:
        retainAll in interface java.util.Collection<E>
        Overrides:
        retainAll in class CollectionMapper<E,​R>
      • removeIf

        public boolean removeIf​(java.util.function.Predicate<? super R> filter)
        Specified by:
        removeIf in interface java.util.Collection<E>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<E>
        Overrides:
        clear in class CollectionMapper<E,​R>