CloseableIterableOnce
Stay organized with collections
Save and categorize content based on your preferences.
A CloseableIterable
that can be iterated over at most once. Additional calls to
iterator()
will throw an IllegalStateException
.
This class does not override Object.equals
.
Public Constructor Summary
Public Method Summary
void
|
close()
Closes any resources associated with this iterator.
|
Iterator<T>
|
iterator()
Gets the wrapped iterator on the first call, and throws an exception on all subsequent calls.
|
Inherited Method Summary
From class
java.lang.Object
boolean
|
equals(Object arg0)
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
From interface
java.lang.Iterable
void
|
forEach(Consumer<? super T> arg0)
|
abstract
Iterator<T>
|
iterator()
|
Spliterator<T>
|
spliterator()
|
From interface
java.lang.AutoCloseable
Public Constructors
public
CloseableIterableOnce
(Iterator<T> iterator)
Constructs an instance wrapping the given iterator.
Parameters
iterator |
the iterator to wrap |
Throws
NullPointerException |
if iterator is null
|
Public Methods
public
void
close
()
Closes any resources associated with this iterator. This
implementation invalidates the iterator.
public
Iterator<T>
iterator
()
Gets the wrapped iterator on the first call, and throws an exception on all subsequent calls.
Returns
- the wrapped iterator on the first call
Throws
IllegalStateException |
if this method has been called on this instance before
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-03-18 UTC.
[null,null,["Last updated 2025-03-18 UTC."],[],[],null,["# CloseableIterableOnce\n\npublic class **CloseableIterableOnce** extends Object \nimplements [CloseableIterable](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/CloseableIterable)\\\u003cT\\\u003e \nA [CloseableIterable](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/CloseableIterable) that can be iterated over at most once. Additional calls to\n`iterator()` will throw an `IllegalStateException`.\n\n\nThis class does not override `Object.equals`. \n\n### Public Constructor Summary\n\n|---|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| | [CloseableIterableOnce](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/CloseableIterableOnce#CloseableIterableOnce(java.util.Iterator\u003cT\u003e))(Iterator\\\u003cT\\\u003e iterator) Constructs an instance wrapping the given iterator. |\n\n### Public Method Summary\n\n|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| void | [close](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/CloseableIterableOnce#close())() Closes any resources associated with this iterator. |\n| Iterator\\\u003cT\\\u003e | [iterator](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/CloseableIterableOnce#iterator())() Gets the wrapped iterator on the first call, and throws an exception on all subsequent calls. |\n\n### Inherited Method Summary\n\nFrom class java.lang.Object \n\n|------------------|---------------------------|\n| boolean | equals(Object arg0) |\n| final Class\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| String | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nFrom interface [com.google.enterprise.cloudsearch.sdk.CloseableIterable](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/CloseableIterable) \n\n|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract void | [close](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/CloseableIterable#close())() Performs any actions necessary to stop accessing the repository, such as closing the connection. |\n\nFrom interface java.lang.Iterable \n\n|------------------------|-------------------------------------|\n| void | forEach(Consumer\\\u003c? super T\\\u003e arg0) |\n| abstract Iterator\\\u003cT\\\u003e | iterator() |\n| Spliterator\\\u003cT\\\u003e | spliterator() |\n\nFrom interface java.lang.AutoCloseable \n\n|---------------|---------|\n| abstract void | close() |\n\nPublic Constructors\n-------------------\n\n#### public\n**CloseableIterableOnce**\n(Iterator\\\u003cT\\\u003e iterator)\n\nConstructs an instance wrapping the given iterator. \n\n##### Parameters\n\n| iterator | the iterator to wrap |\n|----------|----------------------|\n\n##### Throws\n\n| NullPointerException | if `iterator` is `null` |\n|----------------------|-------------------------|\n\nPublic Methods\n--------------\n\n#### public void\n**close**\n()\n\nCloses any resources associated with this iterator. This\nimplementation invalidates the iterator. \n\n#### public Iterator\\\u003cT\\\u003e\n**iterator**\n()\n\nGets the wrapped iterator on the first call, and throws an exception on all subsequent calls. \n\n##### Returns\n\n- the wrapped iterator on the first call \n\n##### Throws\n\n| IllegalStateException | if this method has been called on this instance before |\n|-----------------------|--------------------------------------------------------|"]]