Skip to content

Commit 2e0deca

Browse files
committed
Update EmptyIterable.java
1 parent 2566f68 commit 2e0deca

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

microsphere-java-core/src/main/java/io/microsphere/collection/EmptyIterable.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,23 @@
1717
package io.microsphere.collection;
1818

1919
/**
20-
* Empty {@link Iterable}
20+
* An empty {@link Iterable} implementation that always returns an empty iterator.
21+
* <p>
22+
* This class is a singleton-friendly extension of {@link IterableAdapter}, primarily useful for representing
23+
* an empty collection view. It guarantees that the method {@link #iterator()} will return an instance of
24+
* {@link EmptyIterator#INSTANCE}, ensuring consistent behavior across uses.
25+
* </p>
2126
*
22-
* @author <a href="mailto:mercyblitz@gmail.com">Mercy<a/>
27+
* <h3>Example Usage</h3>
28+
* <pre>{@code
29+
* Iterable<String> emptyIterable = EmptyIterable.INSTANCE;
30+
* for (String item : emptyIterable) {
31+
* // This loop will not execute as the iterable is empty.
32+
* }
33+
* }</pre>
34+
*
35+
* @param <E> the type of elements returned by the iterator
36+
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
2337
* @see Iterable
2438
* @see EmptyIterator
2539
* @since 1.0.0

0 commit comments

Comments
 (0)