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)
| 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 |
no test coverage detected