![JAR search and dependency download from the Maven repository](/logo.png)
personthecat.catlib.data.collections.NonRecursiveObserverSet Maven / Gradle / Ivy
package personthecat.catlib.data.collections;
import java.util.ArrayList;
import java.util.Collection;
import java.util.function.Consumer;
public class NonRecursiveObserverSet extends SimpleObserverSet {
public NonRecursiveObserverSet() {
super();
}
public NonRecursiveObserverSet(final Collection entries) {
super(entries);
}
@Override
public boolean hasActiveEntries() {
for (final SimpleTrackedEntry entry : this.tracked) {
if (entry.isActive()) {
return true;
}
}
return false;
}
@Override
public void forEach(final Consumer fn) {
if (this.tracked.isEmpty()) {
return;
}
for (final SimpleTrackedEntry entry : new ArrayList<>(this.tracked)) {
if (!(entry.isRemoved() || entry.isActive())) {
entry.setActive(true);
try {
fn.accept(entry.getObserver());
} finally {
entry.setActive(false);
}
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy