Class JsonDependencyNodeVisitor
java.lang.Object
org.apache.maven.plugins.dependency.tree.AbstractSerializingVisitor
org.apache.maven.plugins.dependency.tree.JsonDependencyNodeVisitor
- All Implemented Interfaces:
org.apache.maven.shared.dependency.graph.traversal.DependencyNodeVisitor
public class JsonDependencyNodeVisitor
extends AbstractSerializingVisitor
implements org.apache.maven.shared.dependency.graph.traversal.DependencyNodeVisitor
A dependency node visitor that serializes visited nodes to a writer using the JSON format.
-
Field Summary
FieldsFields inherited from class org.apache.maven.plugins.dependency.tree.AbstractSerializingVisitor
writer
-
Constructor Summary
ConstructorsConstructorDescriptionJsonDependencyNodeVisitor
(Writer writer) Creates a new instance ofJsonDependencyNodeVisitor
. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
appendKeyValue
(StringBuilder sb, int indent, String key, String value) Appends a key value pair to the string builder.private void
appendKeyWithoutComma
(StringBuilder sb, int indent, String key, String value) Appends a key value pair to the string builder without a comma at the end.private void
appendNodeValues
(StringBuilder sb, int indent, org.apache.maven.artifact.Artifact artifact, boolean hasChildren) Appends the artifact values to the string builder.boolean
endVisit
(org.apache.maven.shared.dependency.graph.DependencyNode node) private String
indent
(int indent) Returns a string ofindentChar
for the indent level.boolean
visit
(org.apache.maven.shared.dependency.graph.DependencyNode node) private void
writeChildren
(int indent, org.apache.maven.shared.dependency.graph.DependencyNode node, StringBuilder sb, Set<org.apache.maven.shared.dependency.graph.DependencyNode> visited) Writes the children of the node to the string builder.private void
writeNode
(int indent, org.apache.maven.shared.dependency.graph.DependencyNode node, StringBuilder sb, Set<org.apache.maven.shared.dependency.graph.DependencyNode> visited) Appends the node and its children to the string builder.private void
writeRootNode
(org.apache.maven.shared.dependency.graph.DependencyNode node) Writes the node to the writer.
-
Field Details
-
indentChar
-
-
Constructor Details
-
JsonDependencyNodeVisitor
Creates a new instance ofJsonDependencyNodeVisitor
. The writer will be used to write the output.- Parameters:
writer
- the writer to write to
-
-
Method Details
-
appendNodeValues
private void appendNodeValues(StringBuilder sb, int indent, org.apache.maven.artifact.Artifact artifact, boolean hasChildren) Appends the artifact values to the string builder.- Parameters:
sb
- the string builder to append toindent
- the current indent levelartifact
- the artifact to writehasChildren
- true if the artifact has children
-
appendKeyValue
Appends a key value pair to the string builder.- Parameters:
sb
- the string builder to append toindent
- the current indent levelkey
- the key used as json keyvalue
- the value used as json value
-
appendKeyWithoutComma
Appends a key value pair to the string builder without a comma at the end. This is used for the last children of a node.- Parameters:
sb
- the string builder to append toindent
- the current indent levelkey
- the key used as json keyvalue
- the value used as json value
-
indent
Returns a string ofindentChar
for the indent level.- Parameters:
indent
- the number of indent levels- Returns:
- the string of indent characters