getOrAddOutput method

Node<T> getOrAddOutput(
  1. T nodeValue
)

Gets a Node in the outputs or add it.

Implementation

Node<T> getOrAddOutput(T nodeValue) {
  if (nodeValue == value) return this;

  if (!containsOutput(nodeValue)) {
    var node = _resolveNode(nodeValue);
    return _addOutputNode(node) ??
        (throw StateError(
            "Error adding output node `$nodeValue` to `$value`"));
  }

  var node = _resolveNode(nodeValue);
  assert(_outputs.contains(node));
  return node;
}