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 Comment
Gets theComment
.default @Nullable Comment
boolean
Checks if thisCommentableNode
has theComment
.void
setComment
(@Nullable Comment comment) Sets theComment
.static <T> @NotNull CommentableNode<T>
withComment
(@NotNull Node<T> target, @Nullable Comment comment) Creates aCommentableNode
with the specifiedComment
.Methods inherited from interface com.github.siroshun09.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 aCommentableNode
with the specifiedComment
.If
target
is aCommentableNode
, set the specifiedComment
usingsetComment(Comment)
. Otherwise, wrap thetarget
inCommentedNode
and attach theComment
.- Type Parameters:
T
- a type of object- Parameters:
target
- theNode
to attach the comment tocomment
- theComment
to attach- Returns:
- the
CommentableNode
-
hasComment
boolean hasComment()Checks if thisCommentableNode
has theComment
.- Returns:
true
if thisCommentableNode
has theComment
, otherwisefalse
-
getComment
Gets theComment
.- Returns:
- the
Comment
- Throws:
IllegalStateException
- if thisCommentableNode
does not have theComment
-
getCommentOrNull
- Returns:
- the
Comment
ornull
if thisCommentableNode
does not have theComment
-
setComment
Sets theComment
.
-