com.holonplatform.core.internal

## Enum DefaultContext

- java.lang.Object
- - java.lang.Enum<DefaultContext>
  - - com.holonplatform.core.internal.DefaultContext

- All Implemented Interfaces:
    Context, Serializable, Comparable<DefaultContext>

      public enum DefaultContext
      extends Enum<DefaultContext>
      implements Context

  Default `Context` implementation, using `ContextManager` to access context scopes and resources.
  Since:
    5.0.0

- - ### Enum Constant Summary

    Enum Constants
    Enum Constant and Description
    `INSTANCE`

  - ### Field Summary

    - ### Fields inherited from interface com.holonplatform.core.Context

      `CLASSLOADER_SCOPE_NAME, THREAD_SCOPE_NAME`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `<T> Optional<T>` | `resource(String resourceKey, Class<T> resourceType, ClassLoader classLoader)` Lookup a context resource of `resourceType` class using given `resourceKey`.
    `Optional<ContextScope>` | `scope(String name, ClassLoader classLoader)` Gets a registered `ContextScope` with the given `name` and bound to given `classLoader`.
    `static DefaultContext` | `valueOf(String name)` Returns the enum constant of this type with the specified name.
    `static DefaultContext[]` | `values()` Returns an array containing the constants of this enum type, in the order they are declared.

    - ### Methods inherited from class java.lang.Enum

      `compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

    - ### Methods inherited from class java.lang.Object

      `getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface com.holonplatform.core.Context

      `classLoaderScope, classLoaderScope, executeThreadBound, executeThreadBound, get, resource, resource, resource, scope, threadScope, threadScope`

- - ### Enum Constant Detail

    - #### INSTANCE

          public static final DefaultContext INSTANCE

  - ### Method Detail

    - #### values

          public static DefaultContext[] values()

      Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:

          for (DefaultContext c : DefaultContext.values())
              System.out.println(c);

      Returns:
        an array containing the constants of this enum type, in the order they are declared

    - #### valueOf

          public static DefaultContext valueOf(String name)

      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
        `name` - the name of the enum constant to be returned.
      Returns:
        the enum constant with the specified name
      Throws:
        `IllegalArgumentException` - if this enum type has no constant with the specified name
        `NullPointerException` - if the argument is null

    - #### scope

          public Optional<ContextScope> scope(String name,
                                              ClassLoader classLoader)

      Description copied from interface: `Context`
      Gets a registered `ContextScope` with the given `name` and bound to given `classLoader`.
      Specified by:
        `scope` in interface `Context`
      Parameters:
        `name` - Scope name (not null)
        `classLoader` - ClassLoader, if `null`, the default ClassLoader is used
      Returns:
        The registered `ContextScope` with given name, or an empty Optional if a scope with such name is not registered in context

    - #### resource

          public <T> Optional<T> resource(String resourceKey,
                                          Class<T> resourceType,
                                          ClassLoader classLoader)

      Description copied from interface: `Context`
      Lookup a context resource of `resourceType` class using given `resourceKey`.

      All registered context scopes are invoked, in the order defined by `ContextScope.getOrder()` precedence value. The first not `null` resource instance obtained from a scope is the one returned to caller, if any.

      Specified by:
        `resource` in interface `Context`
      Type Parameters:
        `T` - Resource type
      Parameters:
        `resourceKey` - Resource key (not null)
        `resourceType` - Required resource type (not null)
        `classLoader` - ClassLoader to use. If `null`, the default ClassLoader is used.
      Returns:
        Optional resource instance, empty if not available from context

Copyright © 2019 The Holon Platform. All rights reserved.