package com.hypixel.hytale.component.dependency; import com.hypixel.hytale.component.ComponentRegistry; import com.hypixel.hytale.component.system.ISystem; import java.util.Set; import javax.annotation.Nonnull; public class RootDependency extends Dependency { private static final RootDependency FIRST = new RootDependency(OrderPriority.CLOSEST); private static final RootDependency LAST = new RootDependency(OrderPriority.FURTHEST); private static final Set> FIRST_SET = Set.of(FIRST); private static final Set> LAST_SET = Set.of(LAST); public static RootDependency first() { return (RootDependency)FIRST; } public static RootDependency last() { return (RootDependency)LAST; } public static Set> firstSet() { return (Set>)FIRST_SET; } public static Set> lastSet() { return (Set>)LAST_SET; } public RootDependency(int priority) { super(Order.AFTER, priority); } public RootDependency(@Nonnull OrderPriority priority) { super(Order.AFTER, priority); } @Override public void validate(@Nonnull ComponentRegistry registry) { } @Override public void resolveGraphEdge(@Nonnull ComponentRegistry registry, @Nonnull ISystem thisSystem, @Nonnull DependencyGraph graph) { if (this.order == Order.BEFORE) { throw new UnsupportedOperationException("RootDependency can't have Order.BEFORE!"); } else { graph.addEdgeFromRoot(thisSystem, this.priority); } } @Nonnull @Override public String toString() { return "SystemDependency{} " + super.toString(); } }