Skip to content

Commit 3ddf1ad

Browse files
committed
Add IOIterator.adapt(Iterable)
1 parent 4de7c71 commit 3ddf1ad

4 files changed

Lines changed: 24 additions & 6 deletions

File tree

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<modelVersion>4.0.0</modelVersion>
2525
<groupId>commons-io</groupId>
2626
<artifactId>commons-io</artifactId>
27-
<version>2.16.2-SNAPSHOT</version>
27+
<version>2.17.0-SNAPSHOT</version>
2828
<name>Apache Commons IO</name>
2929

3030
<inceptionYear>2002</inceptionYear>
@@ -125,9 +125,9 @@ file comparators, endian transformation classes, and much more.
125125
<commons.componentid>io</commons.componentid>
126126
<commons.module.name>org.apache.commons.io</commons.module.name>
127127
<commons.rc.version>RC2</commons.rc.version>
128-
<commons.bc.version>2.16.0</commons.bc.version>
129-
<commons.release.version>2.16.1</commons.release.version>
130-
<commons.release.next>2.16.2</commons.release.next>
128+
<commons.bc.version>2.16.1</commons.bc.version>
129+
<commons.release.version>2.17.0</commons.release.version>
130+
<commons.release.next>2.17.1</commons.release.next>
131131
<project.build.outputTimestamp>2024-04-08T16:56:47Z</project.build.outputTimestamp>
132132
<commons.release.desc>(requires Java 8)</commons.release.desc>
133133
<commons.jira.id>IO</commons.jira.id>

src/changes/changes.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ The <action> type attribute can be add,update,fix,remove.
4646
<title>Apache Commons IO Release Notes</title>
4747
</properties>
4848
<body>
49-
<release version="2.16.2" date="YYYY-MM-DD" description="Java 8 is required.">
49+
<release version="2.17.0" date="YYYY-MM-DD" description="Java 8 is required.">
5050
<!-- ADD -->
5151
<action dev="ggregory" type="fix" due-to="sullis">Add test for CircularByteBuffer clear() #620.</action>
52+
<action dev="ggregory" type="fix" due-to="Gary Gregory">Add IOIterator.adapt(Iterable).</action>
5253
<!-- FIX -->
5354
<action dev="ggregory" type="fix" due-to="Dependabot">Add missing unit tests.</action>
5455
<action dev="ggregory" type="fix" due-to="Dependabot">FileUtils.lastModifiedFileTime(File) calls Objects.requireNonNull() on the wrong object.</action>

src/main/java/org/apache/commons/io/function/IOIterator.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@
3232
*/
3333
public interface IOIterator<E> {
3434

35+
/**
36+
* Adapts the given Iterable as an IOIterator.
37+
*
38+
* @param <E> the type of the stream elements.
39+
* @param iterable The iterable to adapt
40+
* @return A new IOIterator
41+
* @since 2.17.0
42+
*/
43+
static <E> IOIterator<E> adapt(final Iterable<E> iterable) {
44+
return IOIteratorAdapter.adapt(iterable.iterator());
45+
}
46+
3547
/**
3648
* Adapts the given Iterator as an IOIterator.
3749
*

src/test/java/org/apache/commons/io/function/IOIteratorTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,15 @@ private List<Path> newPathList() {
5151
}
5252

5353
@Test
54-
public void testAdapt() throws IOException {
54+
public void testAdaptIterator() throws IOException {
5555
assertEquals(TestConstants.ABS_PATH_A, iterator.next());
5656
}
5757

58+
@Test
59+
public void testAdaptIterable() throws IOException {
60+
assertEquals(TestConstants.ABS_PATH_A, IOIterator.adapt(newPathList()).next());
61+
}
62+
5863
@Test
5964
public void testAsIterator() {
6065
final Iterator<Path> asIterator = iterator.asIterator();

0 commit comments

Comments
 (0)