cdc.util.enums.AbstractBaseDagSupport Maven / Gradle / Ivy
package cdc.util.enums;
import java.util.function.Consumer;
public abstract class AbstractBaseDagSupport extends AbstractBaseListSupport implements DagType {
protected AbstractBaseDagSupport(Class cls,
DagFeature... features) {
super(cls, features);
}
protected final void iterateUnder(V value,
Consumer consumer) {
consumer.accept(value);
for (final V child : getChildren(value)) {
iterateUnder(child, consumer);
}
}
protected final void iterateOver(V value,
Consumer consumer) {
consumer.accept(value);
for (final V parent : getParents(value)) {
iterateOver(parent, consumer);
}
}
protected final void checkIsNotOverOrEqual(V value,
V other) {
if (other != null) {
iterateOver(other,
v -> {
if (v == value) {
throw new IllegalArgumentException(value + " is over or equal to " + other);
}
});
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy