Commit graph

239 commits

Author SHA1 Message Date
d82a7d6e9f NoteItem: replace empty target node properly 2016-05-24 13:13:55 +01:00
aaab7bbe67 Reorganise code 2016-05-24 11:56:14 +01:00
180f325f79 NodeItemTest: overhaul of test suite 2016-05-24 11:56:14 +01:00
b456e18316 NodeItem: fix up 2016-05-24 11:56:14 +01:00
45bd77bbca Node.placeNodeIn(): add node to tree under the path of named elements
Any intervening nodes that don't exist will be created.

e.g. placeNodeIn(node, "alpha", "beta")

Will add node:

[root]
    "alpha"
        "beta"
            node
2016-05-24 11:56:14 +01:00
9fca56b4c6 Node: remove{Child,Parent}(): split trees branches apart
removeChild(node): removes the node from children of the current node,
making the child node into a new root node.

removeParent(): removes the current from from it's parent's children,
making itself into a new root node.
2016-05-24 11:56:14 +01:00
b2c3032ec0 Node:drawTree(): creates a String representing the node in the tree
The NodeItem implementation on includes nodes with names, or where they
have child nodes. In which case the are shown as '(unnamed)'.
2016-05-24 11:56:14 +01:00
b278fc0f98 Node: add {get,find}ChildNamed() methods
Both methods look for a child with the given name as an immediate child of
the current node.

findChildNamed:

Will return an Optional containing the found node or empty.

getChildNames:

Is more insistent and will return the found node itself. If a node by that
name is not found, then a NodeException will be thrown.
2016-05-24 11:56:14 +01:00
b18020708b Node: may have names and a functional name supplier
Names, where present, must be unique for each parent.

Node:
* String getName()
* void setName(String name)
* boolean isNamed()

NodeItem - replaces all constructor:
* (data)
* (data, name)
* (data, nameSupplier)
* (data, parent)
* (data, nameSupplier, parent)


The name supplier takes a node and generates a string at the time the node
is constructed. The root node has a default name supplier that returns null
which means that the node is considered unnamed. Other nodes may provide
their own name supplier that would be used be new nodes created within
their subtree.
2016-05-24 11:56:14 +01:00
36efe5d83a Node: may be empty, having no data
* isEmpty()
2016-05-24 11:56:14 +01:00
921cf98b13 Add assertj-core dependency for testing 2016-05-24 11:56:14 +01:00
The Gitter Badger
58a84c4fa5 Add Gitter badge 2016-05-18 06:51:26 +00:00
c6cc3ec9d9 Merge pull request #2 from kemitix/update-code-style
Update code style
2016-03-14 15:56:47 +00:00
8187a28795 NodeItemTest: use val and Assert.assertThat()
* Lombok's val simplfies the local variable declarations
* Assert.assertThat() gives better error messages
* javadoc tidy

Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
2016-03-14 15:51:44 +00:00
24ad03ccab NodeExceptionTest: use lombok's val
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
2016-03-14 15:43:56 +00:00
58363e474d NodeItem: apply code style
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
2016-03-14 15:43:21 +00:00
9daebcea46 {Node,NodeItem}: javadoc tidy
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
2016-03-14 15:42:53 +00:00
d9d19a849e NodeItem.findOrCreateChild(): use Optional.orElseGet() to simplify
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
2016-03-14 15:42:07 +00:00
d60f6ae0bb NodeItem.isChildOf(): simplify if statements
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
2016-03-14 15:41:23 +00:00
79170b898a NodeItem: initialise children set in field and make final
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
2016-03-14 15:40:51 +00:00
1aa2daf14b Add lombok back for use in testing only
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
2016-03-14 15:39:47 +00:00
d0c6b07b66 .idea - fixup 2016-03-14 15:39:16 +00:00
fee38dc929 .idea: add IntelliJ configuration
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
2016-03-14 14:35:57 +00:00
7ce9d9d336 Merge pull request #1 from kemitix/drop-lombok
Drop lombok dependency
2016-03-14 14:31:07 +00:00
635af8089d Drop lombok dependency
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
2016-03-14 14:17:14 +00:00
85bd763e09 NodeItem.walkTree(): refactor using existing getChild()
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
2016-01-09 18:09:38 +00:00
c8acd884e1 Merge branch release/0.1.0 into master
Initial Release

Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
2016-01-09 18:00:33 +00:00
bff6b5be5e Merge branch release/0.1.0 into develop
Initial Release

Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
2016-01-09 18:00:33 +00:00
06a2890325 CHANGELOG
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
2016-01-09 18:00:33 +00:00
9479ae6c14 pom.xml: version set to 0.2.0-SNAPSHOT
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
2016-01-09 18:00:33 +00:00
d74d44ba9d pom.xml: version set to 0.1.0
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
2016-01-09 18:00:33 +00:00
1f508bc3d2 README.md: fix typo
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
2016-01-09 17:55:24 +00:00
749dd506ad README.md: fix typo
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
2016-01-09 17:53:46 +00:00
271679e006 README.md: add usage and examples
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
2016-01-09 17:51:36 +00:00
10a0ff71dd .travis.yml: added
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
2016-01-09 17:19:54 +00:00
e977725fbf CHANGELOG: added
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
2016-01-09 17:14:30 +00:00
f50d25493c Merge remote-tracking branch 'origin/master' into develop 2016-01-09 17:12:08 +00:00
8698052a4d Initial commit 2016-01-09 17:10:37 +00:00
8cd57711b8 Initial commit 2016-01-09 17:08:52 +00:00