Class ClassSubsetIterator<T>

  • Type Parameters:
    T - the type of the Iterator
    All Implemented Interfaces:
    Iterator<T>

    public class ClassSubsetIterator<T>
    extends Object
    implements Iterator<T>
    Iterator, which returns only classes, which are a substitute of a given class.
    E.g: 1) B extends A, C extends B 2) list with items of type: [A,B,B,C,A,C,C]
    -> ClassSubSetIterator<A>(list, Class<A>) would return during iteration: [A,B,B,C,A,C,C] since all classes extend A
    -> ClassSubSetIterator<B>(list, Class<B>) would return during iteration: [B,B,C,C,C] since C extends B, but A does not extend B
    -> ClassSubSetIterator<C>(list, Class<C>) would return during iteration: [C,C,C] since only C is a valid substitute of C
    • Constructor Detail

      • ClassSubsetIterator

        public ClassSubsetIterator​(Iterator<?> base,
                                   Class<T> conditionalClass)
    • Method Detail

      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface Iterator<T>
      • next

        public T next()
        Specified by:
        next in interface Iterator<T>
      • remove

        public void remove()
        Specified by:
        remove in interface Iterator<T>