package org.argeo.util.register; import java.util.Map; import java.util.SortedSet; import java.util.function.Predicate; /** A register of components which can coordinate their activation. */ public interface ComponentRegister { long register(Component component); SortedSet> find(Class clss, Predicate> filter); default Component.PublishedType getSingleton(Class type) { SortedSet> found = find(type, null); if (found.size() == 0) throw new IllegalStateException("No component found for " + type); return found.first().getType(type); } default T getObject(Class clss) { SortedSet> found = find(clss, null); if (found.size() == 0) return null; return found.first().get(); } Component get(Object instance); // default PublishedType getType(Class clss) { // SortedSet> components = find(clss, null); // if (components.size() == 0) // return null; // return components.first().getType(clss); // } void activate(); void deactivate(); boolean isActive(); void clear(); }