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 TypeMethodDescriptionvoid
close()
Closes allElement
instances within thisElementRegistry
and closes the registry itself.Returns a new subordinate registry.onClose
(Consumer<ElementRegistry> onClose) Adds aConsumer
to thisElementRegistry
which will get called when it is closed.Adds aConsumer
to thisElementRegistry
which will get called when anEvent
is sourced from anElement
within this registry.void
stream()
Streams allElement
isntances in thisElementRegistry
.boolean
unregister
(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, wait
Methods inherited from interface dev.getelements.elements.sdk.ElementRegistry
find
Methods inherited from interface dev.getelements.elements.sdk.MutableElementRegistry
register
-
Constructor Details
-
RootElementRegistry
public RootElementRegistry() -
RootElementRegistry
-
-
Method Details
-
stream
Description copied from interface:ElementRegistry
Streams allElement
isntances in thisElementRegistry
.- Specified by:
stream
in interfaceElementRegistry
- Returns:
- the
Stream
ofElement
s
-
register
Description copied from interface:MutableElementRegistry
- Specified by:
register
in interfaceMutableElementRegistry
- Parameters:
element
- theElementLoader
to supply theElement
-
unregister
Description copied from interface:MutableElementRegistry
Unregisters anElement
, provided it was previously registered.- Specified by:
unregister
in interfaceMutableElementRegistry
- Returns:
- if the Element existed, and was successfully removed.
-
newSubordinateRegistry
Description copied from interface:ElementRegistry
Returns a new subordinate registry. This registry will be linked to this registry and inherit all currently registeredElement
s contained in. Searching the new subordinate registry will make all registeredElement
s available that are available to this registry. The returnedMutableElementRegistry
will receive events from thisElementRegistry
and forward them along to allElement
s therein. This allows anElement
to load private instances as it sees fit without affecting its parent's hierarchy and thus enforcing encapsulation.- Specified by:
newSubordinateRegistry
in interfaceElementRegistry
- Returns:
- a new subordinate
-
publish
Description copied from interface:ElementRegistry
- Specified by:
publish
in interfaceElementRegistry
- Parameters:
event
- the event
-
onEvent
Description copied from interface:ElementRegistry
Adds aConsumer
to thisElementRegistry
which will get called when anEvent
is sourced from anElement
within this registry.- Specified by:
onEvent
in interfaceElementRegistry
- Parameters:
onEvent
- the event consumer- Returns:
- a
Subscription
to the event
-
onClose
Description copied from interface:ElementRegistry
Adds aConsumer
to thisElementRegistry
which will get called when it is closed.- Specified by:
onClose
in interfaceElementRegistry
- Parameters:
onClose
- the on close consumer- Returns:
- a
Subscription
to the event
-
close
public void close()Description copied from interface:ElementRegistry
Closes allElement
instances within thisElementRegistry
and closes the registry itself.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceElementRegistry
-