Skip to content

Commit 8508dfb

Browse files
committed
Javadoc
1 parent 2207f9a commit 8508dfb

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/main/java/org/apache/commons/io/build/AbstractOrigin.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.apache.commons.io.build;
1919

2020
import java.io.ByteArrayInputStream;
21+
import java.io.Closeable;
2122
import java.io.File;
2223
import java.io.FileInputStream;
2324
import java.io.FileNotFoundException;
@@ -67,7 +68,24 @@
6768
* expose only the operations that make sense for the underlying source or sink; invoking an unsupported operation
6869
* results in {@link UnsupportedOperationException} (see, for example, {@link #getFile()} and {@link #getPath()}).
6970
* </p>
70-
*
71+
* <p>
72+
* An instance doesn't own its origin, it holds on to it to allow conversions. There are two use cases related to resource management for a Builder:
73+
* </p>
74+
* <ul>
75+
* <li>
76+
* A client allocates a {@linkplain Closeable} (or {@linkplain AutoCloseable}) resource, creates a Builder, and gives the Builder that resource by calling a
77+
* setter method. No matter what happens next, the client is responsible for releasing the resource ({@code Closeable.close()}). In this case, the origin
78+
* wraps but doesn't own the closeable resource. There is no transfer of ownership.
79+
* </li>
80+
* <li>
81+
* A client creates a Builder and gives it a non-Closeable object, like a File or a Path. The client then calls the Builder's factory method
82+
* (like {@linkplain #get()}), and that call returns a Closeable or a resource that requires releasing in some other way. No matter what happens next, the
83+
* client is responsible for releasing that resource. In this case, the origin doesn't wrap a closeable resource.
84+
* </li>
85+
* </ul>
86+
* <p>
87+
* In both cases, the client causes the allocation and is responsible for releasing the resource.
88+
* </p>
7189
* <p>
7290
* The table below summarizes which views and conversions are supported for each origin type.
7391
* Column headers show the target view; cells indicate whether that view is available from the origin in that row.

0 commit comments

Comments
 (0)