Class BreakableIterator<E>

Type Parameters:
E - the element type.
All Implemented Interfaces:
Iterator<E>, Breakable, SupportedMethods

public class BreakableIterator<E> extends AbstractBreakable implements Iterator<E>

An iterator that can be broken in well-defined ways in order to test collection utilities or testing classes.

Breaks

The breaks that are supported for this class are listed in the description of the method that they impact.

Any breaks that are not listed in this class can be added to an instance of BreakableIterator, but will not have any impact on how it functions.

Since:
1.0
Author:
evanbergstrom
See Also:
  • Field Details

    • ITERATOR_IS_ALWAYS_EMPTY

      public static final Break ITERATOR_IS_ALWAYS_EMPTY
      The iterator will always have no elements
    • ITERATOR_SKIPS_FIRST_ELEMENT

      public static final Break ITERATOR_SKIPS_FIRST_ELEMENT
      The iterator will skip the first element.
    • ITERATOR_HAS_NEXT_ALWAYS_RETURNS_TRUE

      public static final Break ITERATOR_HAS_NEXT_ALWAYS_RETURNS_TRUE
      The iterator hasNext method will always return a true.
      See Also:
    • ITERATOR_HAS_NEXT_ALWAYS_RETURNS_FALSE

      public static final Break ITERATOR_HAS_NEXT_ALWAYS_RETURNS_FALSE
      The iterator hasNext method will always return a false.
      See Also:
    • ITERATOR_HAS_NEXT_RETURNS_OPPOSITE_VALUE

      public static final Break ITERATOR_HAS_NEXT_RETURNS_OPPOSITE_VALUE
      The iterator hasNext method will always return the opposite value
      See Also:
    • ITERATOR_NEXT_ALWAYS_RETURNS_NULL

      public static final Break ITERATOR_NEXT_ALWAYS_RETURNS_NULL
      The iterator next method will always return null
      See Also:
    • ITERATOR_NEXT_THROWS_WRONG_EXCEPTION

      public static final Break ITERATOR_NEXT_THROWS_WRONG_EXCEPTION
      The iterator next method will always return null
      See Also:
    • ITERATOR_REMOVE_DOES_NOT_REMOVE_ELEMENT

      public static final Break ITERATOR_REMOVE_DOES_NOT_REMOVE_ELEMENT
      The iterator 'remove' method does not remove the element at the current iterator position.
      See Also:
    • ITERATOR_REMOVE_THROWS_WRONG_EXCEPTION_FOR_ILLEGAL_STATE

      public static final Break ITERATOR_REMOVE_THROWS_WRONG_EXCEPTION_FOR_ILLEGAL_STATE
      The iterator 'remove' method throws the wrong exception for an illegal state
      See Also:
    • ITERATOR_REMOVE_THROWS_WRONG_EXCEPTION_IF_NOT_SUPPORTED

      public static final Break ITERATOR_REMOVE_THROWS_WRONG_EXCEPTION_IF_NOT_SUPPORTED
      The iterator 'remove' method throws the wrong exception nif it is not supported.
      See Also:
    • ITERATOR_FOR_EACH_REMAINING_DOES_NOT_CALL_ACTION

      public static final Break ITERATOR_FOR_EACH_REMAINING_DOES_NOT_CALL_ACTION
      The iterator 'forEachRemaining' does not call the action
      See Also:
    • ITERATOR_FOR_EACH_REMAINING_THROWS_WRONG_EXCEPTION_FOR_NULL_ARGUMENT

      public static final Break ITERATOR_FOR_EACH_REMAINING_THROWS_WRONG_EXCEPTION_FOR_NULL_ARGUMENT
      The iterator 'forEachRemaining' throws the wrong exception for a null argument.
      See Also:
  • Constructor Details

    • BreakableIterator

      public BreakableIterator(Iterator<E> iterator, Collection<Break> breaks, int characteristics)
      Constructs a breakable iterator from a iterator that will provide the implementation.
      Parameters:
      iterator - The iterator that will provide the implementation
      breaks - The breaks that define how the iterator is broken.
      characteristics - A mask that indicates the characteristics of the iterator.
  • Method Details