diff --git a/.gitignore b/.gitignore index b311b8d..4bfa550 100644 --- a/.gitignore +++ b/.gitignore @@ -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/ *.iml - -# Spring -spring.log -logs/ -/application.properties -/bootstrap.properties - -# Composer-style -vendor - -# Git and temp files -*.orig -*.patch -*~ +target/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8d04cab..0000000 --- a/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -language: java -jdk: - - oraclejdk8 -after_success: - - mvn clean test jacoco:report coveralls:report diff --git a/CHANGELOG b/CHANGELOG index abf9d93..f111812 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,16 @@ 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 ------ @@ -24,7 +34,6 @@ CHANGELOG * Upgrade kemitix-parent to 2.1.0 * Upgrade lombok to 1.16.10 * Upgrade assertj to 3.5.2 -* 0.4.0 ------ diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy new file mode 100644 index 0000000..90b4535 --- /dev/null +++ b/Jenkinsfile.groovy @@ -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") +} diff --git a/LICENSE.txt b/LICENSE.txt index 00c515a..7607e05 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,23 +1,20 @@ -/* -The MIT License (MIT) - -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. -*/ +/** + * 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. + */ diff --git a/README.md b/README.md deleted file mode 100644 index 97607ff..0000000 --- a/README.md +++ /dev/null @@ -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`: - - - net.kemitix - node - ${node.version} - - -The library consits of an interface `Node` and an implementation `NodeItem`. - -## Create a root node - - Node root = new NodeItem<>("[root]"); - -## Get the contents of the node - - String rootData = root.getData(); // returns "[root]" - -## Add a child node - - Node child = root.createChild("child"); - -Which is shorthand for: - - Node child = new NodeItem<>("child"); - root.addChild(child); - -The tree now looks like: - - "[root]" - \-> "child" - -## Get the child node - - Node 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> 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> children = root.getChildren(); - children.size(); // returns 2 ("child" and "alpha") diff --git a/README.org b/README.org new file mode 100644 index 0000000..117be48 --- /dev/null +++ b/README.org @@ -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 + + net.kemitix + node + ${node.version} + + #+END_SRC + + The library consits of an interface =Node= and an implementation =NodeItem=. + +** Create a root node + + #+BEGIN_SRC java + Node 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 child = root.createChild("child"); + #+END_SRC + + Which is shorthand for: + + #+BEGIN_SRC java + Node 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 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> 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> children = root.getChildren(); + children.size(); + // returns 2 ("child" and "alpha") + #+END_SRC diff --git a/pom.xml b/pom.xml index e47b505..46554be 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 node - 0.7.0 + DEV-SNAPSHOT jar Node @@ -11,16 +11,21 @@ net.kemitix kemitix-parent - 2.4.0 + 5.2.0 + - 1.16.12 - 3.6.2 - 4.3.0 + 1.8 + 2.12 + 1.3.1 + 4.0.1 + 1.18.2 + 3.11.1 2.1.0 4.12 1.3 + 97% @@ -38,17 +43,13 @@ 2016 - - - - org.eluder.coveralls - coveralls-maven-plugin - ${coveralls-maven-plugin.version} - - - - + + org.projectlombok + lombok + ${lombok.version} + provided + junit junit @@ -74,4 +75,22 @@ test + + + + + io.repaint.maven + tiles-maven-plugin + ${tiles-maven-plugin.version} + true + + + net.kemitix.tiles:all:${kemitix-maven-tiles.version} + + net.kemitix.checkstyle:tile:${kemitix-checkstyle.version} + + + + + diff --git a/src/main/java/net/kemitix/node/EmptyNodeException.java b/src/main/java/net/kemitix/node/EmptyNodeException.java index 16e3dfe..4b91851 100644 --- a/src/main/java/net/kemitix/node/EmptyNodeException.java +++ b/src/main/java/net/kemitix/node/EmptyNodeException.java @@ -1,26 +1,23 @@ -/* -The MIT License (MIT) - -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. -*/ +/** + * 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. + */ package net.kemitix.node; diff --git a/src/main/java/net/kemitix/node/ImmutableNodeItem.java b/src/main/java/net/kemitix/node/ImmutableNodeItem.java index 547dde3..da2a7af 100644 --- a/src/main/java/net/kemitix/node/ImmutableNodeItem.java +++ b/src/main/java/net/kemitix/node/ImmutableNodeItem.java @@ -1,26 +1,23 @@ -/* -The MIT License (MIT) - -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. -*/ +/** + * 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. + */ package net.kemitix.node; diff --git a/src/main/java/net/kemitix/node/Node.java b/src/main/java/net/kemitix/node/Node.java index 4a0e67a..62bf838 100644 --- a/src/main/java/net/kemitix/node/Node.java +++ b/src/main/java/net/kemitix/node/Node.java @@ -1,26 +1,23 @@ -/* -The MIT License (MIT) - -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. -*/ +/** + * 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. + */ package net.kemitix.node; diff --git a/src/main/java/net/kemitix/node/NodeException.java b/src/main/java/net/kemitix/node/NodeException.java index f401b6e..39b6aae 100644 --- a/src/main/java/net/kemitix/node/NodeException.java +++ b/src/main/java/net/kemitix/node/NodeException.java @@ -1,26 +1,23 @@ -/* -The MIT License (MIT) - -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. -*/ +/** + * 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. + */ package net.kemitix.node; diff --git a/src/main/java/net/kemitix/node/NodeItem.java b/src/main/java/net/kemitix/node/NodeItem.java index d876c8f..e03cde9 100644 --- a/src/main/java/net/kemitix/node/NodeItem.java +++ b/src/main/java/net/kemitix/node/NodeItem.java @@ -1,31 +1,27 @@ -/* -The MIT License (MIT) - -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. -*/ +/** + * 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. + */ package net.kemitix.node; import lombok.NonNull; -import lombok.ToString; import lombok.val; import java.util.Arrays; @@ -42,7 +38,6 @@ import java.util.stream.Stream; * * @author Paul Campbell (pcampbell@kemitix.net) */ -@ToString(exclude = {"children", "data", "parent"}) @SuppressWarnings("methodcount") class NodeItem implements Node { @@ -76,7 +71,7 @@ class NodeItem implements Node { * * @param newParent The new parent node */ - protected void forceParent(final Node newParent) { + void forceParent(final Node newParent) { this.parent = newParent; } @@ -141,6 +136,7 @@ class NodeItem implements Node { doSetParent(parent); } + @SuppressWarnings("npathcomplexity") private void doSetParent(@NonNull final Node newParent) { if (this.equals(newParent) || newParent.isDescendantOf(this)) { throw new NodeException("Parent is a descendant"); @@ -264,6 +260,7 @@ class NodeItem implements Node { * @return the child or null */ @Override + @SuppressWarnings("npathcomplexity") public Optional> findInPath(@NonNull final List path) { if (path.isEmpty()) { return Optional.empty(); @@ -332,6 +329,7 @@ class NodeItem implements Node { } @Override + @SuppressWarnings("movevariableinsideif") public String drawTree(final int depth) { final StringBuilder sb = new StringBuilder(); final String unnamed = "(unnamed)"; diff --git a/src/main/java/net/kemitix/node/Nodes.java b/src/main/java/net/kemitix/node/Nodes.java index e650d73..bf1ae0c 100644 --- a/src/main/java/net/kemitix/node/Nodes.java +++ b/src/main/java/net/kemitix/node/Nodes.java @@ -1,26 +1,23 @@ -/* -The MIT License (MIT) - -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. -*/ +/** + * 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. + */ package net.kemitix.node; diff --git a/src/main/java/net/kemitix/node/OrphanedNodeException.java b/src/main/java/net/kemitix/node/OrphanedNodeException.java index 4f8587e..815de5e 100644 --- a/src/main/java/net/kemitix/node/OrphanedNodeException.java +++ b/src/main/java/net/kemitix/node/OrphanedNodeException.java @@ -1,26 +1,23 @@ -/* -The MIT License (MIT) - -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. -*/ +/** + * 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. + */ package net.kemitix.node; diff --git a/src/main/java/net/kemitix/node/package-info.java b/src/main/java/net/kemitix/node/package-info.java index 49ea507..98a1b5d 100644 --- a/src/main/java/net/kemitix/node/package-info.java +++ b/src/main/java/net/kemitix/node/package-info.java @@ -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. */