Class MagicRuntimeConfigBinding<C, T extends AutoCloseable>

java.lang.Object
dev.ua.theroer.magicutils.bootstrap.MagicRuntimeConfigBinding<C,T>
Type Parameters:
C - config type
T - resource type
All Implemented Interfaces:
AutoCloseable

public final class MagicRuntimeConfigBinding<C, T extends AutoCloseable> extends Object implements AutoCloseable
Config-aware runtime resource binding.

The binding keeps a managed resource in sync with a config instance and rebuilds it whenever matching config sections change.

  • Method Details

    • name

      public String name()
      Returns the resource name used in the runtime registry.
      Returns:
      resource name
    • configClass

      public Class<C> configClass()
      Returns the bound config class.
      Returns:
      config class
    • resource

      public MagicRuntimeResource<T> resource()
      Returns the managed resource handle.
      Returns:
      managed resource handle
    • isClosed

      public boolean isClosed()
      Returns true when the binding has been closed.
      Returns:
      closed flag
    • current

      public Optional<T> current()
      Returns the current resource when present.
      Returns:
      optional current resource
    • require

      public T require()
      Returns the current resource or throws when absent.
      Returns:
      current resource
    • refresh

      @Nullable public T refresh()
      Rebuilds the resource from the current config instance.
      Returns:
      rebuilt resource, or null when the factory returned null
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable