NodeImpl constructor
NodeImpl(])
creates a fully fledged new empty node.
@param name the name for the node @param parent the parent of the node (may be null if root node is the parent) @param vis visibility of the node
Implementation
NodeImpl(String name, String nodeOwner,
[String? parent,
Visibility vis = Visibility.red,
List<NodeValue> nodeValues = const <NodeValue>[]]) {
if (name.contains(GenericController.pathDelimiter) && parent != null) {
throw StorageException(
'name may not contain a "${GenericController.pathDelimiter}" when providing a name');
}
if (parent == null) {
_ordinals[Field.path] = name;
} else if (parent == GenericController.pathDelimiter) {
_ordinals[Field.path] = '${GenericController.pathDelimiter}$name';
} else {
_ordinals[Field.path] = '$parent${GenericController.pathDelimiter}$name';
}
_checkName(path);
if (parent != null && !parent.startsWith(GenericController.pathDelimiter)) {
throw StorageException(
'path must start with a ${GenericController.pathDelimiter}');
}
if (parent != null &&
parent.endsWith(GenericController.pathDelimiter) &&
parent.length > 1) {
throw StorageException(
'path must not end with a ${GenericController.pathDelimiter}');
}
if (_ordinals[Field.path]!.contains(
'${GenericController.pathDelimiter}${GenericController.pathDelimiter}')) {
throw StorageException(
'path must not contain two ${GenericController.pathDelimiter} in a row (got ${_ordinals[Field.path]})');
}
if (nodeValues.isNotEmpty) {
for (NodeValue val in nodeValues) {
_values[val.key] = val;
}
}
owner = nodeOwner;
_ordinals[Field.visibility] = vis.toValueString();
_skeleton.set(false);
}