Switch to trunk-based-development (#34)

* 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%
This commit is contained in:
Paul Campbell 2018-10-09 22:08:43 +01:00 committed by GitHub
parent 5fbbc604bd
commit daf9821887
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 439 additions and 332 deletions

34
.gitignore vendored
View file

@ -1,35 +1,3 @@
# Package Files #
*.jar
*.war
*.ear
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
# maven build outputs
target/
# netbeans legacy
nbproject/
nbactions.xml
# eclipse legacy
.project
# intellij
.idea/ .idea/
*.iml *.iml
target/
# Spring
spring.log
logs/
/application.properties
/bootstrap.properties
# Composer-style
vendor
# Git and temp files
*.orig
*.patch
*~

View file

@ -1,5 +0,0 @@
language: java
jdk:
- oraclejdk8
after_success:
- mvn clean test jacoco:report coveralls:report

View file

@ -1,6 +1,16 @@
CHANGELOG CHANGELOG
========= =========
NEXT
-----
* Bump kemitix-parent to 5.2.0
* Bump assertj from 3.11.1
* Bump lombok from 1.18.2
* Add kemitix-maven-tiles 0.8.1
* [checkstyle] suppress npath complexity issues
* [coverage] lower requirements
0.7.0 0.7.0
------ ------
@ -24,7 +34,6 @@ CHANGELOG
* Upgrade kemitix-parent to 2.1.0 * Upgrade kemitix-parent to 2.1.0
* Upgrade lombok to 1.16.10 * Upgrade lombok to 1.16.10
* Upgrade assertj to 3.5.2 * Upgrade assertj to 3.5.2
*
0.4.0 0.4.0
------ ------

106
Jenkinsfile.groovy Normal file
View file

@ -0,0 +1,106 @@
final String publicRepo = 'https://github.com/kemitix/'
final String mvn = "mvn --batch-mode --update-snapshots --errors"
final dependenciesSupportJDK = 11
pipeline {
agent any
stages {
stage('Build & Test') {
steps {
withMaven(maven: 'maven', jdk: 'JDK 1.8') {
sh "${mvn} clean compile checkstyle:checkstyle pmd:pmd test"
// Code Coverage to Codacy
sh "${mvn} jacoco:report com.gavinmogan:codacy-maven-plugin:coverage " +
"-DcoverageReportFile=target/site/jacoco/jacoco.xml " +
"-DprojectToken=`$JENKINS_HOME/codacy/token` " +
"-DapiToken=`$JENKINS_HOME/codacy/apitoken` " +
"-Dcommit=`git rev-parse HEAD`"
// Code Coverage to Jenkins
jacoco exclusionPattern: '**/*{Test|IT|Main|Application|Immutable}.class'
// PMD to Jenkins
pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: ''
// Checkstyle to Jenkins
step([$class: 'hudson.plugins.checkstyle.CheckStylePublisher',
pattern: '**/target/checkstyle-result.xml',
healthy:'20',
unHealthy:'100'])
}
}
}
stage('Verify & Install') {
steps {
withMaven(maven: 'maven', jdk: 'JDK 1.8') {
sh "${mvn} -DskipTests install"
}
}
}
stage('SonarQube (published)') {
when { expression { isPublished(publicRepo) } }
steps {
withSonarQubeEnv('sonarqube') {
withMaven(maven: 'maven', jdk: 'JDK 1.8') {
sh "${mvn} org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar"
}
}
}
}
stage('Deploy (published release branch)') {
when {
expression {
(isReleaseBranch() &&
isPublished(publicRepo) &&
notSnapshot())
}
}
steps {
withMaven(maven: 'maven', jdk: 'JDK 1.8') {
sh "${mvn} --activate-profiles release deploy"
}
}
}
stage('Build Java 9') {
when { expression { dependenciesSupportJDK >= 9 } }
steps {
withMaven(maven: 'maven', jdk: 'JDK 9') {
sh "${mvn} clean verify -Djava.version=9"
}
}
}
stage('Build Java 10') {
when { expression { dependenciesSupportJDK >= 10 } }
steps {
withMaven(maven: 'maven', jdk: 'JDK 10') {
sh "${mvn} clean verify -Djava.version=10"
}
}
}
stage('Build Java 11') {
when { expression { dependenciesSupportJDK >= 11 } }
steps {
withMaven(maven: 'maven', jdk: 'JDK 11') {
sh "${mvn} clean verify -Djava.version=11"
}
}
}
}
}
private boolean isReleaseBranch() {
return branchStartsWith('release/')
}
private boolean branchStartsWith(final String branchName) {
startsWith(env.GIT_BRANCH, branchName)
}
private boolean isPublished(final String repo) {
startsWith(env.GIT_URL, repo)
}
private static boolean startsWith(final String value, final String match) {
value != null && value.startsWith(match)
}
private boolean notSnapshot() {
return !(readMavenPom(file: 'pom.xml').version).contains("SNAPSHOT")
}

View file

@ -1,23 +1,20 @@
/* /**
The MIT License (MIT) * The MIT License (MIT)
*
Copyright (c) 2016 Paul Campbell * Copyright (c) 2018 Paul Campbell
*
Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
of this software and associated documentation files (the "Software"), to deal * and associated documentation files (the "Software"), to deal in the Software without restriction,
in the Software without restriction, including without limitation the rights * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
copies of the Software, and to permit persons to whom the Software is * subject to the following conditions:
furnished to do so, subject to the following conditions: *
* The above copyright notice and this permission notice shall be included in all copies
The above copyright notice and this permission notice shall be included in all * or substantial portions of the Software.
copies or substantial portions of the Software. *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

View file

@ -1,69 +0,0 @@
[![Build Status](https://travis-ci.org/kemitix/node.svg?branch=develop)](https://travis-ci.org/kemitix/node)
[![Coverage Status](https://coveralls.io/repos/github/kemitix/node/badge.svg?branch=develop)](https://coveralls.io/github/kemitix/node?branch=develop)
# node
[![Join the chat at https://gitter.im/kemitix/node](https://badges.gitter.im/kemitix/node.svg)](https://gitter.im/kemitix/node?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
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]"
|-> "child"
\-> "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")

104
README.org Normal file
View file

@ -0,0 +1,104 @@
* 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=:
#+BEGIN_SRC xml
<dependency>
<groupId>net.kemitix</groupId>
<artifactId>node</artifactId>
<version>${node.version}</version>
</dependency>
#+END_SRC
The library consits of an interface =Node= and an implementation =NodeItem=.
** Create a root node
#+BEGIN_SRC java
Node<String> root = new NodeItem<>("[root]");
#+END_SRC
** Get the contents of the node
#+BEGIN_SRC java
String rootData = root.getData(); // returns "[root]"
#+END_SRC
** Add a child node
#+BEGIN_SRC java
Node<String> child = root.createChild("child");
#+END_SRC
Which is shorthand for:
#+BEGIN_SRC java
Node<String> child = new NodeItem<>("child");
root.addChild(child);
#+END_SRC
The tree now looks like:
#+BEGIN_EXAMPLE
"[root]"
\-> "child"
#+END_EXAMPLE
** Get the child node
#+BEGIN_SRC java
Node<String> childNode = root.getChild("child");
#+END_SRC
** Create a chain of nodes
#+BEGIN_SRC java
root.createDescendantLine(Arrays.asList("alpha", "beta", "gamma"));
#+END_SRC
#+BEGIN_EXAMPLE
"[root]"
\-> "alpha"
\-> "beta"
\-> "gamma"
#+END_EXAMPLE
** Walk the tree to find a node
#+BEGIN_SRC java
Optional<Node<String>> foundNode = root.walkTree(Arrays.asList("alpha", "beta", "gamma"));
if (foundNode.isPresent()) {
String betaData = foundNode.get().getParent().getData();
// returns "beta"
}
#+END_SRC
** Get all children of a node
#+BEGIN_SRC java
Set<Node<String>> children = root.getChildren();
children.size();
// returns 2 ("child" and "alpha")
#+END_SRC

49
pom.xml
View file

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>node</artifactId> <artifactId>node</artifactId>
<version>0.7.0</version> <version>DEV-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>Node</name> <name>Node</name>
@ -11,16 +11,21 @@
<parent> <parent>
<groupId>net.kemitix</groupId> <groupId>net.kemitix</groupId>
<artifactId>kemitix-parent</artifactId> <artifactId>kemitix-parent</artifactId>
<version>2.4.0</version> <version>5.2.0</version>
<relativePath/>
</parent> </parent>
<properties> <properties>
<lombok.version>1.16.12</lombok.version> <java.version>1.8</java.version>
<assertj.version>3.6.2</assertj.version> <tiles-maven-plugin.version>2.12</tiles-maven-plugin.version>
<coveralls-maven-plugin.version>4.3.0</coveralls-maven-plugin.version> <kemitix-maven-tiles.version>1.3.1</kemitix-maven-tiles.version>
<kemitix-checkstyle.version>4.0.1</kemitix-checkstyle.version>
<lombok.version>1.18.2</lombok.version>
<assertj.version>3.11.1</assertj.version>
<trajano-commons-testing.version>2.1.0</trajano-commons-testing.version> <trajano-commons-testing.version>2.1.0</trajano-commons-testing.version>
<junit.version>4.12</junit.version> <junit.version>4.12</junit.version>
<hamcrest.version>1.3</hamcrest.version> <hamcrest.version>1.3</hamcrest.version>
<jacoco-class-instruction-covered-ratio>97%</jacoco-class-instruction-covered-ratio>
</properties> </properties>
<issueManagement> <issueManagement>
@ -38,17 +43,13 @@
<inceptionYear>2016</inceptionYear> <inceptionYear>2016</inceptionYear>
<build>
<plugins>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>${coveralls-maven-plugin.version}</version>
</plugin>
</plugins>
</build>
<dependencies> <dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
@ -74,4 +75,22 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>${tiles-maven-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<tiles>
<tile>net.kemitix.tiles:all:${kemitix-maven-tiles.version}</tile>
<!--<tile>net.kemitix.tiles:pmd-strict:${kemitix-tiles.version}</tile>-->
<tile>net.kemitix.checkstyle:tile:${kemitix-checkstyle.version}</tile>
</tiles>
</configuration>
</plugin>
</plugins>
</build>
</project> </project>

View file

@ -1,26 +1,23 @@
/* /**
The MIT License (MIT) * The MIT License (MIT)
*
Copyright (c) 2016 Paul Campbell * Copyright (c) 2018 Paul Campbell
*
Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
of this software and associated documentation files (the "Software"), to deal * and associated documentation files (the "Software"), to deal in the Software without restriction,
in the Software without restriction, including without limitation the rights * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
copies of the Software, and to permit persons to whom the Software is * subject to the following conditions:
furnished to do so, subject to the following conditions: *
* The above copyright notice and this permission notice shall be included in all copies
The above copyright notice and this permission notice shall be included in all * or substantial portions of the Software.
copies or substantial portions of the Software. *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package net.kemitix.node; package net.kemitix.node;

View file

@ -1,26 +1,23 @@
/* /**
The MIT License (MIT) * The MIT License (MIT)
*
Copyright (c) 2016 Paul Campbell * Copyright (c) 2018 Paul Campbell
*
Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
of this software and associated documentation files (the "Software"), to deal * and associated documentation files (the "Software"), to deal in the Software without restriction,
in the Software without restriction, including without limitation the rights * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
copies of the Software, and to permit persons to whom the Software is * subject to the following conditions:
furnished to do so, subject to the following conditions: *
* The above copyright notice and this permission notice shall be included in all copies
The above copyright notice and this permission notice shall be included in all * or substantial portions of the Software.
copies or substantial portions of the Software. *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package net.kemitix.node; package net.kemitix.node;

View file

@ -1,26 +1,23 @@
/* /**
The MIT License (MIT) * The MIT License (MIT)
*
Copyright (c) 2016 Paul Campbell * Copyright (c) 2018 Paul Campbell
*
Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
of this software and associated documentation files (the "Software"), to deal * and associated documentation files (the "Software"), to deal in the Software without restriction,
in the Software without restriction, including without limitation the rights * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
copies of the Software, and to permit persons to whom the Software is * subject to the following conditions:
furnished to do so, subject to the following conditions: *
* The above copyright notice and this permission notice shall be included in all copies
The above copyright notice and this permission notice shall be included in all * or substantial portions of the Software.
copies or substantial portions of the Software. *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package net.kemitix.node; package net.kemitix.node;

View file

@ -1,26 +1,23 @@
/* /**
The MIT License (MIT) * The MIT License (MIT)
*
Copyright (c) 2016 Paul Campbell * Copyright (c) 2018 Paul Campbell
*
Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
of this software and associated documentation files (the "Software"), to deal * and associated documentation files (the "Software"), to deal in the Software without restriction,
in the Software without restriction, including without limitation the rights * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
copies of the Software, and to permit persons to whom the Software is * subject to the following conditions:
furnished to do so, subject to the following conditions: *
* The above copyright notice and this permission notice shall be included in all copies
The above copyright notice and this permission notice shall be included in all * or substantial portions of the Software.
copies or substantial portions of the Software. *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package net.kemitix.node; package net.kemitix.node;

View file

@ -1,31 +1,27 @@
/* /**
The MIT License (MIT) * The MIT License (MIT)
*
Copyright (c) 2016 Paul Campbell * Copyright (c) 2018 Paul Campbell
*
Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
of this software and associated documentation files (the "Software"), to deal * and associated documentation files (the "Software"), to deal in the Software without restriction,
in the Software without restriction, including without limitation the rights * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
copies of the Software, and to permit persons to whom the Software is * subject to the following conditions:
furnished to do so, subject to the following conditions: *
* The above copyright notice and this permission notice shall be included in all copies
The above copyright notice and this permission notice shall be included in all * or substantial portions of the Software.
copies or substantial portions of the Software. *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package net.kemitix.node; package net.kemitix.node;
import lombok.NonNull; import lombok.NonNull;
import lombok.ToString;
import lombok.val; import lombok.val;
import java.util.Arrays; import java.util.Arrays;
@ -42,7 +38,6 @@ import java.util.stream.Stream;
* *
* @author Paul Campbell (pcampbell@kemitix.net) * @author Paul Campbell (pcampbell@kemitix.net)
*/ */
@ToString(exclude = {"children", "data", "parent"})
@SuppressWarnings("methodcount") @SuppressWarnings("methodcount")
class NodeItem<T> implements Node<T> { class NodeItem<T> implements Node<T> {
@ -76,7 +71,7 @@ class NodeItem<T> implements Node<T> {
* *
* @param newParent The new parent node * @param newParent The new parent node
*/ */
protected void forceParent(final Node<T> newParent) { void forceParent(final Node<T> newParent) {
this.parent = newParent; this.parent = newParent;
} }
@ -141,6 +136,7 @@ class NodeItem<T> implements Node<T> {
doSetParent(parent); doSetParent(parent);
} }
@SuppressWarnings("npathcomplexity")
private void doSetParent(@NonNull final Node<T> newParent) { private void doSetParent(@NonNull final Node<T> newParent) {
if (this.equals(newParent) || newParent.isDescendantOf(this)) { if (this.equals(newParent) || newParent.isDescendantOf(this)) {
throw new NodeException("Parent is a descendant"); throw new NodeException("Parent is a descendant");
@ -264,6 +260,7 @@ class NodeItem<T> implements Node<T> {
* @return the child or null * @return the child or null
*/ */
@Override @Override
@SuppressWarnings("npathcomplexity")
public Optional<Node<T>> findInPath(@NonNull final List<T> path) { public Optional<Node<T>> findInPath(@NonNull final List<T> path) {
if (path.isEmpty()) { if (path.isEmpty()) {
return Optional.empty(); return Optional.empty();
@ -332,6 +329,7 @@ class NodeItem<T> implements Node<T> {
} }
@Override @Override
@SuppressWarnings("movevariableinsideif")
public String drawTree(final int depth) { public String drawTree(final int depth) {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
final String unnamed = "(unnamed)"; final String unnamed = "(unnamed)";

View file

@ -1,26 +1,23 @@
/* /**
The MIT License (MIT) * The MIT License (MIT)
*
Copyright (c) 2016 Paul Campbell * Copyright (c) 2018 Paul Campbell
*
Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
of this software and associated documentation files (the "Software"), to deal * and associated documentation files (the "Software"), to deal in the Software without restriction,
in the Software without restriction, including without limitation the rights * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
copies of the Software, and to permit persons to whom the Software is * subject to the following conditions:
furnished to do so, subject to the following conditions: *
* The above copyright notice and this permission notice shall be included in all copies
The above copyright notice and this permission notice shall be included in all * or substantial portions of the Software.
copies or substantial portions of the Software. *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package net.kemitix.node; package net.kemitix.node;

View file

@ -1,26 +1,23 @@
/* /**
The MIT License (MIT) * The MIT License (MIT)
*
Copyright (c) 2016 Paul Campbell * Copyright (c) 2018 Paul Campbell
*
Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
of this software and associated documentation files (the "Software"), to deal * and associated documentation files (the "Software"), to deal in the Software without restriction,
in the Software without restriction, including without limitation the rights * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
copies of the Software, and to permit persons to whom the Software is * subject to the following conditions:
furnished to do so, subject to the following conditions: *
* The above copyright notice and this permission notice shall be included in all copies
The above copyright notice and this permission notice shall be included in all * or substantial portions of the Software.
copies or substantial portions of the Software. *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package net.kemitix.node; package net.kemitix.node;

View file

@ -1,26 +1,24 @@
/* /**
The MIT License (MIT) * The MIT License (MIT)
*
* Copyright (c) 2018 Paul Campbell
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies
* or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
* AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
Copyright (c) 2016 Paul Campbell
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/** /**
* Tree Node implementation. * Tree Node implementation.
*/ */