Interface ReloadShell<C>

Type Parameters:
C - the type of the config

public interface ReloadShell<C>
A handler for managing reloading of an inner configuration object.

This handler provides a proxy, called the shell (getShell()) which delegates all calls made on it to an inner delegate. The delegate can also be set or get via this interface. If the current delegate is null, calls to methods on the shell will throw NullPointerException.

  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable C
    Gets the current inner delegate
    @NonNull C
    Gets the configuration shell, a proxy to the current delegate.
    void
    setCurrentDelegate(@Nullable C delegate)
    Sets the inner configuration object to the provided value.
  • Method Details

    • setCurrentDelegate

      void setCurrentDelegate(@Nullable C delegate)
      Sets the inner configuration object to the provided value.

      This function is thread safe; the assignment is performed with at least acquire/release semantics.

      Parameters:
      delegate - the delegate value
      Throws:
      IllegalArgumentException - if the argument to delegate is the shell itself, or creates a cycle (such as with other ReloadShells) pointing to the shell
    • getCurrentDelegate

      @Nullable C getCurrentDelegate()
      Gets the current inner delegate
      Returns:
      the delegate value
    • getShell

      @NonNull C getShell()
      Gets the configuration shell, a proxy to the current delegate.

      Methods called on it will reflect the latest state of the configuration (set with setCurrentDelegate(Object)) at the time of the method call. Thus, the proxy acts as convenient wrapper that automatically returns up-to-date values.

      This means the shell itself (the returned value) can be conveniently stored in multiple locations, without needing to update these fields when the underlying configuration (the delegate) is reloaded.

      Returns:
      the configuration shell, a proxy to the current delegate