BridgeRegistry
class BridgeRegistry<T extends IBridge>
Known subtypes: UIBridgeRegistry
Package: dev.joid.lib.bridge · Module: core · Source: BridgeRegistry.java
An ordered set of bridges of one kind, kept sorted by priority, whose highest bridge answers get().
Description
Section titled “Description”Every registry of BridgeHandler is a BridgeRegistry.
Registering and unregistering are synchronized and publish a new read-only list, so reading never locks.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
| BridgeRegistry(String name) | Creates an empty registry; the name, such as "RENDER", appears in the exception of get() on an empty registry. |
Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
void | register(T bridge) | Registers a bridge with the priority 0. |
void | register(T bridge, int priority) | Registers a bridge with a priority: the highest priority comes first. |
void | unregister(T bridge) | Removes a bridge; does nothing when the bridge is not registered. |
void | registerDefault(T bridge) | Registers a bridge with the lowest priority, Integer.MIN_VALUE, only when the registry is empty, so that any bridge registered later comes before it. |
T | get() | Returns the bridge of highest priority. |
B | getBridge(Class bridgeClass) | Returns the bridge of highest priority that is an instance of the class, or null when there is none. |
T | find(Predicate | Returns the bridge of highest priority that the filter accepts, or null when the filter accepts none. |
List<T> | getBridgeList() | Returns the registered bridges, read-only, from the lowest priority to the highest. |
Creation details
Section titled “Creation details”BridgeRegistry
Section titled “BridgeRegistry”BridgeRegistry(String name)
Creates an empty registry; the name, such as "RENDER", appears in the exception of get() on an empty registry.
Method details
Section titled “Method details”register
Section titled “register”void register(T bridge)
Registers a bridge with the priority 0.
void register(T bridge, int priority)
Registers a bridge with a priority: the highest priority comes first. Among bridges of the same priority, the last one registered comes first; a bridge that is already registered moves to its new priority.
unregister
Section titled “unregister”void unregister(T bridge)
Removes a bridge; does nothing when the bridge is not registered.
registerDefault
Section titled “registerDefault”void registerDefault(T bridge)
Registers a bridge with the lowest priority, Integer.MIN_VALUE, only when the registry is empty, so that any bridge registered later comes before it.
Backends use it for their default UI bridge.
T get()
Throws:
IllegalStateException: No … bridge registered, call BridgeHandler.….register before using JOID
Returns the bridge of highest priority.
Throws an IllegalStateException that names the registry when it is empty, which usually means that no backend is registered.
getBridge
Section titled “getBridge”<B extends T> B getBridge(Class<B> bridgeClass)
Returns the bridge of highest priority that is an instance of the class, or null when there is none.
T find(Predicate<T> filter)
Returns the bridge of highest priority that the filter accepts, or null when the filter accepts none.
getBridgeList
Section titled “getBridgeList”List<T> getBridgeList()
Returns the registered bridges, read-only, from the lowest priority to the highest. The list is a snapshot: a later registration does not change it.
fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses
