Package dev.getelements.elements.sdk.spi
Class RootElementRegistry
java.lang.Object
dev.getelements.elements.sdk.spi.RootElementRegistry
- All Implemented Interfaces:
ElementRegistry,MutableElementRegistry,AutoCloseable
Implements
ElementRegistry at the root level with no parent. This should be used by the application at the
top-level. Note that when registering-
Field Summary
Fields inherited from interface dev.getelements.elements.sdk.ElementRegistry
ROOT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes allElementinstances within thisElementRegistryand closes the registry itself.Returns a new subordinate registry.onClose(Consumer<ElementRegistry> onClose) Adds aConsumerto thisElementRegistrywhich will get called when it is closed.Adds aConsumerto thisElementRegistrywhich will get called when anEventis sourced from anElementwithin this registry.voidstream()Streams allElementisntances in thisElementRegistry.booleanunregister(Element element) Unregisters anElement, provided it was previously registered.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.getelements.elements.sdk.ElementRegistry
findMethods inherited from interface dev.getelements.elements.sdk.MutableElementRegistry
register
-
Constructor Details
-
RootElementRegistry
public RootElementRegistry() -
RootElementRegistry
-
-
Method Details
-
stream
Description copied from interface:ElementRegistryStreams allElementisntances in thisElementRegistry.- Specified by:
streamin interfaceElementRegistry- Returns:
- the
StreamofElements
-
register
Description copied from interface:MutableElementRegistry- Specified by:
registerin interfaceMutableElementRegistry- Parameters:
element- theElementLoaderto supply theElement
-
unregister
Description copied from interface:MutableElementRegistryUnregisters anElement, provided it was previously registered.- Specified by:
unregisterin interfaceMutableElementRegistry- Returns:
- if the Element existed, and was successfully removed.
-
newSubordinateRegistry
Description copied from interface:ElementRegistryReturns a new subordinate registry. This registry will be linked to this registry and inherit all currently registeredElements contained in. Searching the new subordinate registry will make all registeredElements available that are available to this registry. The returnedMutableElementRegistrywill receive events from thisElementRegistryand forward them along to allElements therein. This allows anElementto load private instances as it sees fit without affecting its parent's hierarchy and thus enforcing encapsulation.- Specified by:
newSubordinateRegistryin interfaceElementRegistry- Returns:
- a new subordinate
-
publish
Description copied from interface:ElementRegistry- Specified by:
publishin interfaceElementRegistry- Parameters:
event- the event
-
onEvent
Description copied from interface:ElementRegistryAdds aConsumerto thisElementRegistrywhich will get called when anEventis sourced from anElementwithin this registry.- Specified by:
onEventin interfaceElementRegistry- Parameters:
onEvent- the event consumer- Returns:
- a
Subscriptionto the event
-
onClose
Description copied from interface:ElementRegistryAdds aConsumerto thisElementRegistrywhich will get called when it is closed.- Specified by:
onClosein interfaceElementRegistry- Parameters:
onClose- the on close consumer- Returns:
- a
Subscriptionto the event
-
close
public void close()Description copied from interface:ElementRegistryCloses allElementinstances within thisElementRegistryand closes the registry itself.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceElementRegistry
-