Package io.microsphere.collection
Class EmptyIterable<E>
- java.lang.Object
-
- io.microsphere.collection.IterableAdapter<E>
-
- io.microsphere.collection.EmptyIterable<E>
-
- Type Parameters:
E
- the type of elements returned by the iterator
- All Implemented Interfaces:
java.lang.Iterable<E>
public class EmptyIterable<E> extends IterableAdapter<E>
An emptyIterable
implementation that always returns an empty iterator.This class is a singleton-friendly extension of
IterableAdapter
, primarily useful for representing an empty collection view. It guarantees that the methodIterableAdapter.iterator()
will return an instance ofEmptyIterator.INSTANCE
, ensuring consistent behavior across uses.Example Usage
Iterable<String> emptyIterable = EmptyIterable.INSTANCE; for (String item : emptyIterable) { // This loop will not execute as the iterable is empty. }
- Since:
- 1.0.0
- Author:
- Mercy
- See Also:
Iterable
,EmptyIterator
-
-
Field Summary
Fields Modifier and Type Field Description static EmptyIterable
INSTANCE
Singleton instance ofEmptyIterator
-
Constructor Summary
Constructors Constructor Description EmptyIterable()
-
Method Summary
-
Methods inherited from class io.microsphere.collection.IterableAdapter
iterator
-
-
-
-
Field Detail
-
INSTANCE
public static final EmptyIterable INSTANCE
Singleton instance ofEmptyIterator
-
-