Class CollectionMapper<E,​R>

  • All Implemented Interfaces:
    java.lang.Iterable<R>, java.util.Collection<R>
    Direct Known Subclasses:
    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.

    • Field Summary

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

      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()<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()<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>
        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<R> stream()
      • parallelStream

        public<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>
        add in class java.util.AbstractCollection<R>
      • remove

        public boolean remove​(java.lang.Object o)
        Specified by:
        remove in interface java.util.Collection<E>
        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>
        addAll in class java.util.AbstractCollection<R>
      • removeAll

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

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

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