MCPcopy Create free account
hub / github.com/Hypejet/Jet / addChild

Method addChild

api/src/main/java/net/hypejet/jet/event/node/EventNode.java:66–81  ·  view source on GitHub ↗

Adds plain EventNode an event node as a child of this node. Does nothing if this event node already contains the event node specified as a child. @param node the event node @return this event node @since 1.0

(@NonNull EventNode<? extends E> node)

Source from the content-addressed store, hash-verified

64 * @since 1.0
65 */
66 public @NonNull EventNode<E> addChild(@NonNull EventNode<? extends E> node) {
67 Objects.requireNonNull(node, "node");
68 if (!this.eventClass.isAssignableFrom(node.eventClass())) {
69 throw new IllegalArgumentException("You cannot add a child to an event node, whose event class is not" +
70 " assignable from an event class of the child");
71 }
72
73 if (this == node)
74 throw new IllegalArgumentException("You cannot add an event node as a child of itself");
75
76 try (CollectionAcquisition<EventNode<? extends E>, ?> acquisition = this.children.acquireWrite()) {
77 acquisition.collection().add(node);
78 }
79
80 return this;
81 }
82
83 /**
84 * Removes {@linkplain EventNode an event node} as a child from this node. Does nothing if the event node is not

Callers 1

registerMethod · 0.80

Calls 3

collectionMethod · 0.80
addMethod · 0.65
eventClassMethod · 0.45

Tested by

no test coverage detected