Package react4j

Class Contexts

java.lang.Object
react4j.Contexts

public final class Contexts extends Object
A global registry containing the react contexts that have been created. A react context is expected to be registered with a java type and an optional qualifier. This allows multiple contexts of the same type to be present in the global registry.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> Context<T>
    get(Class<T> type)
    Return the context with the specified type and an empty "" qualifier.
    static <T> Context<T>
    get(Class<T> type, String qualifier)
    Return the context with the specified type and qualifier.
    static <T> void
    register(Class<T> type)
    Register the context with the specified type, an empty "" qualifier and a null default value.
    static <T> void
    register(Class<T> type, String qualifier)
    Register the context with the specified type, qualifier and a null default value.
    static <T> void
    register(Class<T> type, String qualifier, T defaultValue)
    Register the context with the specified type, qualifier and a default value.
    static <T> void
    register(Class<T> type, T defaultValue)
    Register the context with the specified type, an empty "" qualifier and a default value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • register

      public static <T> void register(@Nonnull Class<T> type)
      Register the context with the specified type, an empty "" qualifier and a null default value. A context with matching type and qualifier parameters must not have been already registered.
      Type Parameters:
      T - the type of the context value.
      Parameters:
      type - the type of the context value.
      See Also:
    • register

      public static <T> void register(@Nonnull Class<T> type, @Nullable T defaultValue)
      Register the context with the specified type, an empty "" qualifier and a default value. A context with matching type and qualifier parameters must not have been already registered.
      Type Parameters:
      T - the type of the context value.
      Parameters:
      type - the type of the context value.
      defaultValue - the default value to return if no provider has been specified higher in the tree.
      See Also:
    • register

      public static <T> void register(@Nonnull Class<T> type, @Nonnull String qualifier)
      Register the context with the specified type, qualifier and a null default value. A context with matching type and qualifier parameters must not have been already registered.
      Type Parameters:
      T - the type of the context value.
      Parameters:
      type - the type of the context value.
      qualifier - the qualifier to distinguish multiple instances of the the same type.
      See Also:
    • register

      public static <T> void register(@Nonnull Class<T> type, @Nonnull String qualifier, @Nullable T defaultValue)
      Register the context with the specified type, qualifier and a default value. A context with matching type and qualifier parameters must not have been already registered.
      Type Parameters:
      T - the type of the context value.
      Parameters:
      type - the type of the context value.
      qualifier - the qualifier to distinguish multiple instances of the the same type.
      defaultValue - the default value to return if no provider has been specified higher in the tree.
    • get

      public static <T> Context<T> get(@Nonnull Class<T> type)
      Return the context with the specified type and an empty "" qualifier. A context with matching type and qualifier parameters must have already been registered.
      Type Parameters:
      T - the type of the context value.
      Parameters:
      type - the type of the context value.
      Returns:
      the context.
      See Also:
    • get

      public static <T> Context<T> get(@Nonnull Class<T> type, @Nonnull String qualifier)
      Return the context with the specified type and qualifier. A context with matching type and qualifier parameters must have already been registered.
      Type Parameters:
      T - the type of the context value.
      Parameters:
      type - the type of the context value.
      qualifier - the qualifier to distinguish multiple instances of the the same type.
      Returns:
      the context.
      See Also: