421ad743f0
ImmutableNodeItem: added
2016-08-21 19:09:12 +01:00
be0685538f
AbstractNodeItem: added
2016-08-21 19:08:59 +01:00
cf6bc72717
NodeItem: hide package class - use Node interface only
2016-08-21 15:39:02 +01:00
7a10498a31
NodeItem: remove dynamic name support for nodes
2016-08-21 12:46:21 +01:00
1b0b022281
NodeItem.findChild(): rewrite stream filter
2016-08-21 12:46:21 +01:00
2da1d9aa3d
NodeItem: add deprecated to implementation of deprecated interface method
2016-08-21 12:27:50 +01:00
e9b43cb73c
[BREAKING] NodeItem: require instantiation using Nodes
...
This breaks the existing API where NodeItem<T> could be instantiated directly.
2016-08-21 12:22:04 +01:00
51e8194db7
Nodes: add utility class to create Node instances
2016-08-21 12:22:04 +01:00
f945af160a
NodeItem: deprecate dynamic node names
...
With the aim of moving towards immutable objects, node shouldn't have
dynamic names. I've not found a use for them in my own projects.
2016-08-21 11:29:42 +01:00
1ea7802768
NodeItemTest: ensure that removeParent() removes the child from the parent too
2016-05-26 13:17:21 +01:00
136bc0b4ba
NodeItemTest: ensure that when a child is removed from it's parent its parent is removed
2016-05-26 13:11:51 +01:00
d3b8fa721b
NodeItemTest: check that parent is set when using NodeItem(data, supplier, parent)
2016-05-26 13:08:52 +01:00
6c13cd2735
Node.getParent(): returns any parent inside an Optional
...
Root nodes will return an empty Optional.
2016-05-26 13:03:32 +01:00
37562941f4
Node.getChildByName(): javadoc to note throws NodeException if child not found
2016-05-26 13:03:32 +01:00
41bd84b6f6
Node.getData(): nodes may be empty so return an Optional
...
Most tests used Node::getData as a name supplier for test fixtures.
In some cases these were not needed and have been removed. In others, where
there are used, they have been updated to get the content of the Optional.
If the Optional happens to be empty, which it shouldn't be in those cases,
then an error will occur and the test will, correctly, fail.
2016-05-26 13:03:25 +01:00
d0e6769126
NodeItem.insertInPath(): don't hide field 'name'
2016-05-25 14:23:33 +01:00
5d0de83aef
NodeItem.insertInPath(): exception message includes name of conflicting node
2016-05-25 13:47:41 +01:00
e06feddec3
Merge pull request #9 from kemitix/demo-of-full-path-node-name
...
NodeItemTest: demonstrate using dynamic name supplier to generate nod…
2016-05-24 23:03:11 +01:00
d82b0290a1
NodeItemTest: demonstrate using dynamic name supplier to generate node paths
2016-05-24 22:35:24 +01:00
eebd293633
NodeItem.insertInPath(): use setData() to when target is already in tree
...
Where an empty node is already found in the tree where we want to insert
a node, use the setData() method to place the data. This replaces the
previous process of attempting to swapping in the new node.
2016-05-24 22:16:35 +01:00
96ac0f720f
Node.setName(): ensure that setting name to null enables the name supplier
2016-05-24 22:04:00 +01:00
7de6c5ad49
Node.getName(): generated each time called when using a name supplier
...
Previously the name was set when the node was created and only a call to
setName() would have changed it.
isNamed() uses the generated name, so this may change if the generated name
is even null or the empty string.
2016-05-24 22:03:14 +01:00
080d995ba0
NodeItemTest: more tests
2016-05-24 16:36:10 +01:00
a31c4501ac
Fix typos
2016-05-24 15:05:53 +01:00
f95029d348
Node.getChild(): method to get a child or throw an exception if not found
2016-05-24 14:44:03 +01:00
04599861c0
Node.createChild(data, name): can create named child nodes
...
# Conflicts:
# src/test/java/net/kemitix/node/NodeItemTest.java
2016-05-24 14:44:03 +01:00
fc55bacb04
Node.setData(): add ability to change node's data after instantiation
2016-05-24 14:44:03 +01:00
2ed0024bc0
Node: clean up method names
...
Deprecate:
* findOrCreateChild()
Rename:
* getChild() => findChild()
* isChildOf() => isDescendantOf()
* walkTree() => findInPath()
* placeNodeIn() => insertInPath()
* findChildNamed() => findChildByName()
* getChildNamed() => getChildByName()
2016-05-24 14:25:55 +01:00
e9c6300ad4
Node: remove pointless final in parameters in interface
2016-05-24 14:10:46 +01:00
3053eab9b0
NodeItem.drawTree(): fix typo
2016-05-24 13:50:38 +01:00
6f81a62162
NodeItem.removeParent(): use same name supplier in the new root node
2016-05-24 13:33:53 +01:00
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
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
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