From 274a7ed82bb0915f55b7f012aa5ba8dfe912c01c Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Fri, 24 Mar 2023 22:26:38 +0800 Subject: [PATCH] docs: Add more docstrings to methods implemented --- .../utils/settings/node/MVCommentedNode.java | 29 ++++++++++++++- .../utils/settings/node/MVValueNode.java | 37 ++++++++++++++++++- .../utils/settings/node/NamedValueNode.java | 6 ++- 3 files changed, 69 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/settings/node/MVCommentedNode.java b/src/main/java/com/onarandombox/MultiverseCore/utils/settings/node/MVCommentedNode.java index af4ccb19..0a6b0582 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/settings/node/MVCommentedNode.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/settings/node/MVCommentedNode.java @@ -11,7 +11,13 @@ import org.jetbrains.annotations.NotNull; */ public class MVCommentedNode implements CommentedNode { - public static Builder builder(String path) { + /** + * Creates a new builder for a {@link MVCommentedNode}. + * + * @param path The path of the node. + * @return The new builder. + */ + public static Builder builder(String path) { return new Builder<>(path); } @@ -39,15 +45,31 @@ public class MVCommentedNode implements CommentedNode { return comments; } + /** + * Builder for {@link MVCommentedNode}. + * + * @param The type of the builder. + */ public static class Builder { protected final String path; protected final List comments; + /** + * Creates a new builder for a {@link MVCommentedNode}. + * + * @param path The path of the node. + */ protected Builder(String path) { this.path = path; this.comments = new ArrayList<>(); } + /** + * Adds a comment line to the node. + * + * @param comment The comment to add. + * @return This builder. + */ public B comment(@NotNull String comment) { if (!comment.isEmpty() && !comment.trim().startsWith("#")) { // Automatically add a comment prefix if the comment doesn't start with one. @@ -57,6 +79,11 @@ public class MVCommentedNode implements CommentedNode { return (B) this; } + /** + * Builds the node. + * + * @return The built node. + */ public MVCommentedNode build() { return new MVCommentedNode(path, comments.toArray(new String[0])); } diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/settings/node/MVValueNode.java b/src/main/java/com/onarandombox/MultiverseCore/utils/settings/node/MVValueNode.java index e7fcea3f..3783d496 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/settings/node/MVValueNode.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/settings/node/MVValueNode.java @@ -11,6 +11,14 @@ import org.jetbrains.annotations.Nullable; */ public class MVValueNode extends MVCommentedNode implements NamedValueNode { + /** + * Creates a new builder for a {@link MVValueNode}. + * + * @param path The path of the node. + * @param type The type of the value. + * @return The new builder. + * @param The type of the value. + */ public static Builder builder(String path, Class type) { return new Builder<>(path, type); } @@ -50,28 +58,55 @@ public class MVValueNode extends MVCommentedNode implements NamedValueNode return Optional.ofNullable(name); } + /** + * Builder for {@link MVValueNode}. + * + * @param The type of the value. + * @param The type of the builder. + */ public static class Builder> extends MVCommentedNode.Builder { protected final Class type; protected T defaultValue; private String name; - public Builder(@NotNull String path, @NotNull Class type) { + /** + * Creates a new builder. + * + * @param path The path of the node. + * @param type The type of the value. + */ + protected Builder(@NotNull String path, @NotNull Class type) { super(path); this.type = type; this.name = path; } + /** + * Sets the default value for this node. + * + * @param defaultValue The default value. + * @return This builder. + */ public B defaultValue(@NotNull T defaultValue) { this.defaultValue = defaultValue; return (B) this; } + /** + * Sets the name of this node. Used for identifying the node from user input. + * + * @param name The name of this node. + * @return This builder. + */ public B name(@Nullable String name) { this.name = name; return (B) this; } + /** + * {@inheritDoc} + */ @Override public MVValueNode build() { return new MVValueNode<>(path, comments.toArray(new String[0]), type, defaultValue, name); diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/settings/node/NamedValueNode.java b/src/main/java/com/onarandombox/MultiverseCore/utils/settings/node/NamedValueNode.java index 080186bc..0c8891b7 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/settings/node/NamedValueNode.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/settings/node/NamedValueNode.java @@ -3,8 +3,12 @@ package com.onarandombox.MultiverseCore.utils.settings.node; import java.util.Optional; import io.github.townyadvanced.commentedconfiguration.setting.TypedValueNode; -import org.jetbrains.annotations.Nullable; +/** + * A {@link TypedValueNode} that has a name. + * + * @param The type of the node's value. + */ public interface NamedValueNode extends TypedValueNode { /** * Gets the name of this node. Used for identifying the node from user input.