Class ViewRegistry
java.lang.Object
tech.guilhermekaua.spigotboot.inventoryapi.internal.registry.ViewRegistry
Registry of view singletons and their frozen configs, keyed by view class.
Boot-time discovery and dependency-manager instantiation happen in
initialize(Context), mirroring the 2.x InventoryRegistry bootstrap;
views can also be registered directly via register(View).
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a registry without discovery support; views are registered directly throughregister(View).ViewRegistry(@NotNull ViewDiscoveryService discoveryService) Creates the registry with discovery support. -
Method Summary
Modifier and TypeMethodDescription@NotNull Collection<RegisteredView>all()Returns every registration in registration order.@NotNull Optional<RegisteredView>Looks up the registration of a view class.voidinitialize(@NotNull Context context) Discovers@RegisterViewclasses under the host plugin's base package, instantiates each through the dependency manager and registers it.voidRegisters a view instance directly: freezes its token table, runsonInitonce and validates the resulting config.
-
Constructor Details
-
ViewRegistry
public ViewRegistry()Creates a registry without discovery support; views are registered directly throughregister(View). -
ViewRegistry
Creates the registry with discovery support.- Parameters:
discoveryService- the discovery service used byinitialize(Context)
-
-
Method Details
-
initialize
Discovers@RegisterViewclasses under the host plugin's base package, instantiates each through the dependency manager and registers it. A view that fails to instantiate or register is logged SEVERE and skipped; the remaining views still register.- Parameters:
context- the host plugin's application context- Throws:
Exception- when context access fails
-
register
Registers a view instance directly: freezes its token table, runsonInitonce and validates the resulting config.- Parameters:
instance- the view singleton to register- Throws:
ViewConfigurationException- when the built config violates the validation rules or a pagination layout-char target does not match the declared layoutIllegalStateException- when the view class is already registered
-
find
@NotNull public @NotNull Optional<RegisteredView> find(@NotNull @NotNull Class<? extends View> type) Looks up the registration of a view class.- Parameters:
type- the view class to resolve- Returns:
- the registration, or empty when the class is not registered
-
all
Returns every registration in registration order.- Returns:
- all registrations, unmodifiable
-