Class CollectionMapper<E,​R>

  • All Implemented Interfaces:
    java.lang.Iterable<R>, java.util.Collection<R>
    Direct Known Subclasses:
    CacheCollectionMapper, SetMapper, WriteableCacheCollectionMapper

    public class CollectionMapper<E,​R>
    extends java.util.AbstractCollection<R>
    A collection that maps another one to a new one of a possibly different type. Note this collection is read only and doesn't accept write operations.

    Some operations such as Collection.contains(Object) and Collection.containsAll(Collection) may be more expensive then normal since they cannot utilize lookups into the original collection.

    Since:
    9.0
    Author:
    wburns
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.function.Function<? super E,​? extends R> mapper  
      protected java.util.Collection<E> realCollection  
    • Constructor Summary

      Constructors 
      Constructor Description
      CollectionMapper​(java.util.Collection<E> realCollection, java.util.function.Function<? super E,​? extends R> mapper)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(R e)  
      boolean addAll​(java.util.Collection<? extends R> c)  
      void clear()  
      void forEach​(java.util.function.Consumer<? super R> action)  
      boolean isEmpty()  
      java.util.Iterator<R> iterator()  
      java.util.stream.Stream<R> parallelStream()  
      boolean remove​(java.lang.Object o)  
      boolean removeAll​(java.util.Collection<?> c)  
      boolean retainAll​(java.util.Collection<?> c)  
      int size()  
      java.util.Spliterator<R> spliterator()  
      java.util.stream.Stream<R> stream()  
      • Methods inherited from class java.util.AbstractCollection

        contains, containsAll, toArray, toArray, toString
      • Methods inherited from class java.lang.Object

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

        equals, hashCode, removeIf, toArray
    • Field Detail

      • realCollection

        protected final java.util.Collection<E> realCollection
      • mapper

        protected final java.util.function.Function<? super E,​? extends R> mapper
    • Constructor Detail

      • CollectionMapper

        public CollectionMapper​(java.util.Collection<E> realCollection,
                                java.util.function.Function<? super E,​? extends R> mapper)
    • Method Detail

      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<E>
        Specified by:
        size in class java.util.AbstractCollection<R>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection<E>
        Overrides:
        isEmpty in class java.util.AbstractCollection<R>
      • iterator

        public java.util.Iterator<R> iterator()
        Specified by:
        iterator in interface java.util.Collection<E>
        Specified by:
        iterator in interface java.lang.Iterable<E>
        Specified by:
        iterator in class java.util.AbstractCollection<R>
      • spliterator

        public java.util.Spliterator<R> spliterator()
      • stream

        public java.util.stream.Stream<R> stream()
      • parallelStream

        public java.util.stream.Stream<R> parallelStream()
      • forEach

        public void forEach​(java.util.function.Consumer<? super R> action)
      • add

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

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

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

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

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

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