Added javadoc for FluentBuilder
@@ -23,6 +23,13 @@ import org.mqttbee.annotations.Nullable;
import java.util.function.Function;
/**
+ * Base class for builders that implement a fluent builder API.
+ * <p>
+ * A fluent builder knows its parent builder method that consumes the object the builder creates.
+ * Calling {@link #done()} creates the builder's object and hands it over to its parent builder method.
+ *
+ * @param <B> the type of the object the builder creates when {@link #build()} is called
+ * @param <P> the type of the parent builder
* @author Silvio Giebl
*/
public abstract class FluentBuilder<B, P> {
@@ -41,11 +48,22 @@ public abstract class FluentBuilder<B, P> {
this.parentConsumer = parentConsumer;
}
+ /**
+ * Creates the builder's object and hands it over to its parent builder method.
+ * This method must not be called on the root of a fluent builder. Consider calling {@link #build()} instead.
+ *
+ * @return the parent builder.
+ */
@NotNull
public P done() {
return done(build(), parentConsumer);
}
+ /**
+ * Creates this builder's object.
+ *
+ * @return the created object.
+ */
@NotNull
public abstract B build();
