Class IterableOnly<E>
java.lang.Object
org.soliscode.test.interfaces.IterableOnly<E>
- Type Parameters:
E
- the element type.
- All Implemented Interfaces:
Iterable<E>
- Direct Known Subclasses:
CollectionOnly
An iterable that is provided for tests that only implement the
Iterable
interface. If the code that is
being tested tries to detect the kind of iterable to optimize the algorithm, it will be forced to use only the
methods on iterable.- Since:
- 1.0
- Author:
- evanbergstrom
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty iterable.IterableOnly
(Iterable<E> other) Creates a copy of an iterable.IterableOnly
(Collection<E> c) Creates an instance ofIterableOnly
from the collection provided. -
Method Summary
Modifier and TypeMethodDescriptionboolean
int
hashCode()
iterator()
static <E> Iterable
<E> of()
Creates an iterable from an empty collection of elements.static <E> Iterable
<E> of
(E e1) Creates an iterable from a list of one element.static <E> Iterable
<E> of
(E... values) Creates an iterable from a list of one element.static <E> Iterable
<E> of
(E e1, E e2) Creates an iterable from an list of two elements.static <E> Iterable
<E> of
(E e1, E e2, E e3) Creates an iterable from an list of three elements.static <E> Iterable
<E> of
(E e1, E e2, E e3, E e4) Creates an iterable from a list of four elements.toString()
-
Field Details
-
iterable
-
-
Constructor Details
-
IterableOnly
public IterableOnly()Creates an empty iterable. -
IterableOnly
-
IterableOnly
Creates an instance ofIterableOnly
from the collection provided.- Parameters:
c
- The collection of elements.
-
-
Method Details
-
equals
-
hashCode
-
toString
-
iterator
-
spliterator
- Specified by:
spliterator
in interfaceIterable<E>
-
of
Creates an iterable from an empty collection of elements.- Type Parameters:
E
- the element type.- Returns:
- an iterable on an empty collection of elements.
-
of
Creates an iterable from a list of one element.
Iterable<Integer> iterable = IterableOnly.of(1, 2, 3, 4);
- Type Parameters:
E
- the element type.- Parameters:
values
- the array of elements.- Returns:
- an iterable containing the element.
- Throws:
NullPointerException
- if the array isnull
-
of
Creates an iterable from a list of one element.
Iterable<Integer> iterable = IterableOnly.of(1);
- Type Parameters:
E
- the element type.- Parameters:
e1
- the first element.- Returns:
- an iterable containing the specified elements.
- Throws:
NullPointerException
- if the array isnull
-
of
Creates an iterable from an list of two elements.
Iterable<Integer> iterable = IterableOnly.of(1, 2);
- Type Parameters:
E
- the element type.- Parameters:
e1
- the first element.e2
- the second element.- Returns:
- an iterable containing the specified elements.
- Throws:
NullPointerException
- if the array isnull
-
of
Creates an iterable from an list of three elements.
Iterable<Integer> iterable = IterableOnly.of(1, 2, 3);
- Type Parameters:
E
- the element type.- Parameters:
e1
- the first element.e2
- the second element.e3
- the third element.- Returns:
- an iterable containing the specified elements.
- Throws:
NullPointerException
- if the array isnull
-
of
Creates an iterable from a list of four elements.
Iterable<Integer> iterable = IterableOnly.of(1, 2, 3, 4);
- Type Parameters:
E
- the element type.- Parameters:
e1
- the first element.e2
- the second element.e3
- the third element.e4
- the third element.- Returns:
- an iterable containing the specified elements.
- Throws:
NullPointerException
- if the array isnull
-