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 the given node.
|
void |
addComments(List<String> comments)
Adds the given comments to already existing comments at the given node.
|
List<String> |
getComments()
Returns comments at the given 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 the given node.
|
void |
setComments(List<String> comments)
Sets the given comments at the given node.
|
void |
setIgnored(boolean ignored)
Sets if to ignore this block.
|
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 value@Nullable public List<String> getComments()
Expect null
or an empty List
.
Use methods provided by Comments
for extensive manipulation.
public void setComments(@Nullable List<String> comments)
To remove comments, use removeComments()
instead. Alternatively, pass either
null
or an empty List
as the parameter.
Use methods provided by Comments
for extensive manipulation.
comments
- the comments to setpublic void removeComments()
Use methods provided by Comments
for extensive manipulation.
public void addComments(@NotNull List<String> comments)
Use methods provided by Comments
for extensive manipulation.
comments
- the comments to addpublic void addComment(@NotNull String comment)
Use methods provided by Comments
for extensive manipulation.
comment
- the comment to addpublic void setIgnored(boolean ignored)
ignored
- if to ignore this blockpublic boolean isIgnored()
public abstract boolean isSection()
section
.section
public T getStoredValue()
For sections
, this is a Map
; for terminated blocks
an
Object
.
Copyright © 2022. All rights reserved.