Paul Campbell
daf9821887
* pom.xml: version set to 0.8.0-SNAPSHOT * jenkins: added * mvn: add wrapper 3.5.3 * Upgrade parent to 5.1.0 * lombok: upgraded to 1.16.20 * assertj: upgraded to 3.9.1 * coveralls: removed * kemitix-maven-tiles: added * kemitix-checkstyle: tile added * Compile with java 1.8 * Reduce code coverage requirements * LICENSE: update * checkstyle: suppress outstanding npath complexity issues, etc * Bump kemitix-parent from 5.1.0 to 5.1.1 Bumps [kemitix-parent](https://github.com/kemitix/kemitix-parent) from 5.1.0 to 5.1.1. - [Release notes](https://github.com/kemitix/kemitix-parent/releases) - [Changelog](https://github.com/kemitix/kemitix-parent/blob/master/CHANGELOG) - [Commits](https://github.com/kemitix/kemitix-parent/compare/v5.1.0...v5.1.1) Signed-off-by: dependabot[bot] <support@dependabot.com> * Bump tiles-maven-plugin from 2.10 to 2.12 Bumps [tiles-maven-plugin](https://github.com/repaint-io/maven-tiles) from 2.10 to 2.12. - [Release notes](https://github.com/repaint-io/maven-tiles/releases) - [Changelog](https://github.com/repaint-io/maven-tiles/blob/master/CHANGELOG.adoc) - [Commits](https://github.com/repaint-io/maven-tiles/compare/tiles-maven-plugin-2.10...tiles-maven-plugin-2.12) Signed-off-by: dependabot[bot] <support@dependabot.com> * Bump assertj-core from 3.9.1 to 3.11.0 Bumps [assertj-core](https://github.com/joel-costigliola/assertj-core) from 3.9.1 to 3.11.0. - [Release notes](https://github.com/joel-costigliola/assertj-core/releases) - [Commits](https://github.com/joel-costigliola/assertj-core/compare/assertj-core-3.9.1...assertj-core-3.11.0) Signed-off-by: dependabot[bot] <support@dependabot.com> * Bump lombok from 1.16.20 to 1.18.2 Bumps [lombok](https://github.com/rzwitserloot/lombok) from 1.16.20 to 1.18.2. - [Release notes](https://github.com/rzwitserloot/lombok/releases) - [Changelog](https://github.com/rzwitserloot/lombok/blob/master/doc/changelog.markdown) - [Commits](https://github.com/rzwitserloot/lombok/compare/v1.16.20...v1.18.2) Signed-off-by: dependabot[bot] <support@dependabot.com> * Bump assertj-core from 3.11.0 to 3.11.1 Bumps [assertj-core](https://github.com/joel-costigliola/assertj-core) from 3.11.0 to 3.11.1. - [Release notes](https://github.com/joel-costigliola/assertj-core/releases) - [Commits](https://github.com/joel-costigliola/assertj-core/compare/assertj-core-3.11.0...assertj-core-3.11.1) Signed-off-by: dependabot[bot] <support@dependabot.com> * Bump kemitix-parent from 5.1.1 to 5.2.0 Bumps [kemitix-parent](https://gitlab.com/kemitix/kemitix-parent) from 5.1.1 to 5.2.0. - [Release notes](https://gitlab.com/kemitix/kemitix-parent/tags) - [Commits](https://gitlab.com/kemitix/kemitix-parent/commits/master) Signed-off-by: dependabot[bot] <support@dependabot.com> * Update CHANGELOG * Update Jenkinsfile * Remove maven wrapper * Remove travis config * Simplify .gitignore * [readme] convert to org-mode format * lombok scope is provided * version set to DEV-SNAPSHOT * rename property kemitix-tiles as kemitix-maven-tiles * Bump kemitix-maven-tiles from 0.8.1 to 1.3.0 * Bump kemitix-maven-tiles from 1.3.0 to 1.3.1 * NoteItem remove @ToString * Narrow scope of forceParent to package-private * [coverage] set required instructions covered to 97% |
||
---|---|---|
src | ||
.gitignore | ||
CHANGELOG | ||
Jenkinsfile.groovy | ||
LICENSE.txt | ||
pom.xml | ||
README.org |
Node
[[https://oss.sonatype.org/content/repositories/releases/net/kemitix/node][file:https://img.shields.io/nexus/r/https/oss.sonatype.org/net.kemitix/node.svg?style=for-the-badge] [[https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22net.kemitix%22%20AND%20a%3A%22node%22][file:https://img.shields.io/maven-central/v/net.kemitix/node.svg?style=for-the-badge]
[[https://sonarcloud.io/dashboard?id=net.kemitix%3Anode][file:https://img.shields.io/sonar/https/sonarcloud.io/net.kemitix%3Anode/coverage.svg?style=for-the-badge#.svg] [[https://sonarcloud.io/dashboard?id=net.kemitix%3Anode][file:https://img.shields.io/sonar/https/sonarcloud.io/net.kemitix%3Anode/tech_debt.svg?style=for-the-badge#.svg] [[https://sonarcloud.io/dashboard?id=net.kemitix%3Anode][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Anode&metric=sqale_rating#.svg] [[https://sonarcloud.io/dashboard?id=net.kemitix%3Anode][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Anode&metric=alert_status#.svg] [[https://sonarcloud.io/dashboard?id=net.kemitix%3Anode][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Anode&metric=reliability_rating#.svg] [[https://sonarcloud.io/dashboard?id=net.kemitix%3Anode][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Anode&metric=security_rating#.svg] [[https://sonarcloud.io/dashboard?id=net.kemitix%3Anode][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Anode&metric=sqale_index#.svg] [[https://sonarcloud.io/dashboard?id=net.kemitix%3Anode][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Anode&metric=vulnerabilities#.svg] [[https://sonarcloud.io/dashboard?id=net.kemitix%3Anode][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Anode&metric=bugs#.svg] [[https://sonarcloud.io/dashboard?id=net.kemitix%3Anode][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Anode&metric=code_smells#.svg] [[https://sonarcloud.io/dashboard?id=net.kemitix%3Anode][file:https://sonarcloud.io/api/project_badges/measure?project=net.kemitix%3Anode&metric=ncloc#.svg]
[[https://app.codacy.com/project/kemitix/node/dashboard][file:https://img.shields.io/codacy/grade/2b67fc90d79a4402aa29f1a7fcf65d7f.svg?style=for-the-badge] [[http://i.jpeek.org/net.kemitix/node/index.html][file:http://i.jpeek.org/net.kemitix/node/badge.svg]
A parent/children data structure
Usage
Add as a dependency in your pom.xml
:
<dependency>
<groupId>net.kemitix</groupId>
<artifactId>node</artifactId>
<version>${node.version}</version>
</dependency>
The library consits of an interface Node
and an implementation NodeItem
.
Create a root node
Node<String> root = new NodeItem<>("[root]");
Get the contents of the node
String rootData = root.getData(); // returns "[root]"
Add a child node
Node<String> child = root.createChild("child");
Which is shorthand for:
Node<String> child = new NodeItem<>("child");
root.addChild(child);
The tree now looks like:
"[root]" \-> "child"
Get the child node
Node<String> childNode = root.getChild("child");
Create a chain of nodes
root.createDescendantLine(Arrays.asList("alpha", "beta", "gamma"));
"[root]" \-> "alpha" \-> "beta" \-> "gamma"
Walk the tree to find a node
Optional<Node<String>> foundNode = root.walkTree(Arrays.asList("alpha", "beta", "gamma"));
if (foundNode.isPresent()) {
String betaData = foundNode.get().getParent().getData();
// returns "beta"
}
Get all children of a node
Set<Node<String>> children = root.getChildren();
children.size();
// returns 2 ("child" and "alpha")