T - type of the value storedpublic abstract class Block<T> extends Object
| Constructor and Description |
|---|
Block(Block<?> previous,
T value)
Creates a block with the same comments as the provided previous block, with the given value.
|
Block(org.snakeyaml.engine.v2.nodes.Node keyNode,
org.snakeyaml.engine.v2.nodes.Node valueNode,
T value)
Creates a block using the given parameters; while storing references to comments from the given nodes.
|
Block(T value)
Creates a block with the given value, but no comments.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addComment(String comment)
Adds the given comment to already existing comments (at
NodeRole.KEY node at
Comments.Position.BEFORE position). |
void |
addComments(List<String> comments)
Adds the given comments to already existing comments (at
NodeRole.KEY node at
Comments.Position.BEFORE position). |
List<String> |
getComments()
Returns comments (at
NodeRole.KEY node at Comments.Position.BEFORE position). |
T |
getStoredValue()
Returns the stored value.
|
protected void |
init(org.snakeyaml.engine.v2.nodes.Node key,
org.snakeyaml.engine.v2.nodes.Node value)
Stores comments from the given nodes.
|
boolean |
isIgnored()
Returns if this block is ignored.
|
abstract boolean |
isSection()
Returns if this block represents a
section. |
void |
removeComments()
Removes all comments (at
NodeRole.KEY node at Comments.Position.BEFORE position). |
void |
setComments(List<String> comments)
Sets the given comments (at
NodeRole.KEY node at Comments.Position.BEFORE position). |
void |
setIgnored(boolean ignored)
Sets if to ignore this block.
|
void |
setValue(T value)
Sets a new value.
|
public Block(@Nullable
org.snakeyaml.engine.v2.nodes.Node keyNode,
@Nullable
org.snakeyaml.engine.v2.nodes.Node valueNode,
@Nullable
T value)
keyNode - node which represents the key to the blockvalueNode - node which represents the valuevalue - the value to storepublic Block(@Nullable
T value)
This constructor is only used by extending classes, where the comments (respective nodes) are unknown at the
time of initialization. In such a scenario, it is needed to call init(Node, Node) afterwards.
value - the value to storepublic Block(@Nullable
Block<?> previous,
@Nullable
T value)
null, creates a block with no comments.previous - the previous block to reference comments fromvalue - the value to storeprotected void init(@Nullable
org.snakeyaml.engine.v2.nodes.Node key,
@Nullable
org.snakeyaml.engine.v2.nodes.Node value)
This method can also be referred to as the secondary constructor.
key - node which represents the key to the blockvalue - node which represents the valuepublic void setValue(T value)
value - the new value@Nullable public List<String> getComments()
NodeRole.KEY node at Comments.Position.BEFORE position).
This method will return null or an empty List, indicating there are no comments.
Comments.get(Block, NodeRole, Comments.Position)public void setComments(@Nullable
List<String> comments)
NodeRole.KEY node at Comments.Position.BEFORE position).
To remove comments, use removeComments() instead. Alternatively, pass either
null or an empty List as the parameter.
comments - the comments to setComments.set(Block, NodeRole, Comments.Position, List)public void removeComments()
NodeRole.KEY node at Comments.Position.BEFORE position).public void addComments(@NotNull
List<String> comments)
NodeRole.KEY node at
Comments.Position.BEFORE position).comments - the comments to addComments.add(Block, NodeRole, Comments.Position, List)public void addComment(@NotNull
String comment)
NodeRole.KEY node at
Comments.Position.BEFORE position).comment - the comment to addComments.add(Block, NodeRole, Comments.Position, CommentLine)public void setIgnored(boolean ignored)
ignored - if to ignore this blockpublic boolean isIgnored()
public abstract boolean isSection()
section.sectionpublic T getStoredValue()
For sections, this is a Map; for terminated blocks an
Object.
Copyright © 2024. All rights reserved.