Class ListDecorator<L extends java.util.List<E>,​E,​D extends ElementDecorator<E>>

  • Type Parameters:
    L -
    E -
    All Implemented Interfaces:
    java.lang.Iterable<D>, java.util.Collection<D>, java.util.List<D>, org.api4.java.common.attributedobjects.IListDecorator<L,​E,​D>

    public class ListDecorator<L extends java.util.List<E>,​E,​D extends ElementDecorator<E>>
    extends java.lang.Object
    implements org.api4.java.common.attributedobjects.IListDecorator<L,​E,​D>, java.util.List<D>
    This class solves the following problem: Sometimes you want to use objects of a concrete List class L to be used in a context where some extension of the List interface L' is used, which is not implemented by L. To use objects of type L in such a context, it is a bad idea to cast and copy the items of L into an object of type L' but instead a decorator implementing L' should be used that forwards all operations to the original instance. The ListDecorator must be told how to create elements of the decorated list in order to insert
    • Constructor Summary

      Constructors 
      Constructor Description
      ListDecorator​(L list)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.reflect.Constructor<D> getConstructorForDecoratingItems()  
      L getList()  
      java.lang.Class<E> getTypeOfDecoratedItems()  
      java.lang.Class<D> getTypeOfDecoratingItems()  
      • Methods inherited from class java.lang.Object

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

        parallelStream, removeIf, stream, toArray
      • Methods inherited from interface org.api4.java.common.attributedobjects.IListDecorator

        add, add, addAll, addAll, clear, contains, containsAll, get, getDecorationForElement, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.List

        equals, hashCode, replaceAll, sort, spliterator
    • Constructor Detail

      • ListDecorator

        public ListDecorator​(L list)
    • Method Detail

      • getTypeOfDecoratedItems

        public java.lang.Class<E> getTypeOfDecoratedItems()
        Specified by:
        getTypeOfDecoratedItems in interface org.api4.java.common.attributedobjects.IListDecorator<L extends java.util.List<E>,​E,​D extends ElementDecorator<E>>
      • getTypeOfDecoratingItems

        public java.lang.Class<D> getTypeOfDecoratingItems()
        Specified by:
        getTypeOfDecoratingItems in interface org.api4.java.common.attributedobjects.IListDecorator<L extends java.util.List<E>,​E,​D extends ElementDecorator<E>>
      • getConstructorForDecoratingItems

        public java.lang.reflect.Constructor<D> getConstructorForDecoratingItems()
        Specified by:
        getConstructorForDecoratingItems in interface org.api4.java.common.attributedobjects.IListDecorator<L extends java.util.List<E>,​E,​D extends ElementDecorator<E>>
      • getList

        public L getList()
        Specified by:
        getList in interface org.api4.java.common.attributedobjects.IListDecorator<L extends java.util.List<E>,​E,​D extends ElementDecorator<E>>