This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git


The following commit(s) were added to refs/heads/master by this push:
     new f01c32850 Javadoc
f01c32850 is described below

commit f01c32850373d7c80fa77165162fdd8c22f15b96
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Mon Oct 7 21:14:47 2024 -0400

    Javadoc
---
 .../apache/commons/io/build/AbstractSupplier.java  | 93 ++++++++++++++++++++++
 1 file changed, 93 insertions(+)

diff --git a/src/main/java/org/apache/commons/io/build/AbstractSupplier.java 
b/src/main/java/org/apache/commons/io/build/AbstractSupplier.java
index bfbeabad0..61216033e 100644
--- a/src/main/java/org/apache/commons/io/build/AbstractSupplier.java
+++ b/src/main/java/org/apache/commons/io/build/AbstractSupplier.java
@@ -21,6 +21,99 @@ import org.apache.commons.io.function.IOSupplier;
 
 /**
  * Abstracts supplying an instance of {@code T}. Use to implement the builder 
pattern.
+ * <p>
+ * For example, here is a builder, a domain class, and a test.
+ * </p>
+ * <p>
+ * The builder:
+ * </p>
+ * <pre>
+    &#8725;**
+     &ast; Builds Foo instances.
+     &ast;&#8725;
+    public static class Builder extends AbstractSupplier&#60;Foo, Builder&#62; 
{
+
+        private String bar1;
+        private String bar2;
+        private String bar3;
+
+        &#8725;**
+         &ast; Builds a new Foo.
+         &ast;&#8725;
+        &#64;Override
+        public Foo get() {
+            return new Foo(bar1, bar2, bar3);
+        }
+
+        public Builder setBar1(final String bar1) {
+            this.bar1 = bar1;
+            return this;
+        }
+
+        public Builder setBar2(final String bar2) {
+            this.bar2 = bar2;
+            return this;
+        }
+
+        public Builder setBar3(final String bar3) {
+            this.bar3 = bar3;
+            return this;
+        }
+    }
+ * </pre>
+ * <p>
+ * The domain class:
+ * </p>
+ * <pre>
+    &#8725;**
+     &ast; Domain class.
+     &ast;&#8725;
+    public class Foo {
+
+        public static Builder builder() {
+            return new Builder();
+        }
+
+        private final String bar1;
+        private final String bar2;
+        private final String bar3;
+
+        private Foo(final String bar1, final String bar2, final String bar3) {
+            this.bar1 = bar1;
+            this.bar2 = bar2;
+            this.bar3 = bar3;
+        }
+
+        public String getBar1() {
+            return bar1;
+        }
+
+        public String getBar2() {
+            return bar2;
+        }
+
+        public String getBar3() {
+            return bar3;
+        }
+
+    }
+ * </pre>
+ * <p>
+ * The test:
+ * </p>
+ * <pre>
+    &#64;Test
+    public void test() {
+        final Foo foo = Foo.builder()
+            .setBar1("value1")
+            .setBar2("value2")
+            .setBar3("value3")
+            .get();
+        assertEquals("value1", foo.getBar1());
+        assertEquals("value2", foo.getBar2());
+        assertEquals("value3", foo.getBar3());
+    }
+ * </pre>
  *
  * @param <T> the type of instances to build.
  * @param <B> the type of builder subclass.

Reply via email to