Skip to content

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().

Every registry of BridgeHandler is a BridgeRegistry. Registering and unregistering are synchronized and publish a new read-only list, so reading never locks.

ReturnsSignatureSummary
BridgeRegistry(String name)Creates an empty registry; the name, such as "RENDER", appears in the exception of get() on an empty registry.

ReturnsSignatureSummary
voidregister(T bridge)Registers a bridge with the priority 0.
voidregister(T bridge, int priority)Registers a bridge with a priority: the highest priority comes first.
voidunregister(T bridge)Removes a bridge; does nothing when the bridge is not registered.
voidregisterDefault(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.
Tget()Returns the bridge of highest priority.
BgetBridge(Class bridgeClass)Returns the bridge of highest priority that is an instance of the class, or null when there is none.
Tfind(Predicate filter)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.

BridgeRegistry(String name)

Creates an empty registry; the name, such as "RENDER", appears in the exception of get() on an empty registry.

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.

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. 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.

<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.

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

Report a problem with this page