Package dev.siroshun.configapi.core.node
Interface CommentableNode<T>
- Type Parameters:
T- a type of object
- All Superinterfaces:
Node<T>
- All Known Implementing Classes:
CommentedNode
@Experimental
public sealed interface CommentableNode<T>
extends Node<T>
permits CommentedNode<T>, ListNode, MapNode
-
Method Summary
Modifier and TypeMethodDescription@NotNull CommentGets theComment.default @Nullable CommentbooleanChecks if thisCommentableNodehas theComment.voidsetComment(@Nullable Comment comment) Sets theComment.static <T> @NotNull CommentableNode<T>withComment(@NotNull Node<T> target, @Nullable Comment comment) Creates aCommentableNodewith the specifiedComment.Methods inherited from interface dev.siroshun.configapi.core.node.Node
accept, asOptional, hasValue, value
-
Method Details
-
withComment
@NotNull static <T> @NotNull CommentableNode<T> withComment(@NotNull @NotNull Node<T> target, @Nullable @Nullable Comment comment) Creates aCommentableNodewith the specifiedComment.If
targetis aCommentableNode, set the specifiedCommentusingsetComment(Comment). Otherwise, wrap thetargetinCommentedNodeand attach theComment.- Type Parameters:
T- a type of object- Parameters:
target- theNodeto attach the comment tocomment- theCommentto attach- Returns:
- the
CommentableNode
-
hasComment
boolean hasComment()Checks if thisCommentableNodehas theComment.- Returns:
trueif thisCommentableNodehas theComment, otherwisefalse
-
getComment
Gets theComment.- Returns:
- the
Comment - Throws:
IllegalStateException- if thisCommentableNodedoes not have theComment
-
getCommentOrNull
- Returns:
- the
Commentornullif thisCommentableNodedoes not have theComment
-
setComment
Sets theComment.
-