Class MagicRuntimeResource<T extends AutoCloseable>
java.lang.Object
dev.ua.theroer.magicutils.bootstrap.MagicRuntimeResource<T>
- Type Parameters:
T- resource type
- All Implemented Interfaces:
AutoCloseable
public final class MagicRuntimeResource<T extends AutoCloseable>
extends Object
implements AutoCloseable
Managed resource slot owned by a
MagicRuntime.
The slot keeps the current resource under a stable name, exposes it through the runtime's named component registry, and closes replaced/current resources automatically.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()current()Returns the current resource when present.booleanisClosed()Returns true when the slot has been closed.name()Returns the resource name used in the runtime registry.require()Returns the current resource or throws when absent.Installs a new resource, closing the previous one.
-
Method Details
-
name
-
isClosed
public boolean isClosed()Returns true when the slot has been closed.- Returns:
- closed flag
-
current
-
require
-
set
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-