Add EventNode#getParent

This commit is contained in:
TheMode 2021-06-04 00:30:48 +02:00
parent 94e315e3b2
commit f1ddedfb44

View File

@ -123,6 +123,7 @@ public class EventNode<T extends Event> {
public EventNode<T> addChild(@NotNull EventNode<? extends T> child) {
synchronized (GLOBAL_CHILD_LOCK) {
Check.stateCondition(child.parent != null, "Node already has a parent");
Check.stateCondition(Objects.equals(parent, child), "Cannot have a child as parent");
final boolean result = this.children.add((EventNode<T>) child);
if (result) {
@ -209,6 +210,10 @@ public class EventNode<T extends Event> {
return this;
}
public @Nullable EventNode<? super T> getParent() {
return parent;
}
public @NotNull Set<@NotNull EventNode<T>> getChildren() {
return Collections.unmodifiableSet(children);
}