Class Contexts

java.lang.Object
org.eclipse.handly.context.Contexts

public class Contexts extends Object
Provides static utility methods for creating and operating on IContexts.
  • Field Details

    • EMPTY_CONTEXT

      public static final IContext EMPTY_CONTEXT
      The empty context (immutable).
  • Method Details

    • of

      public static <T> IContext of(Property<T> property, T value)
      Returns an immutable context containing only the given property-value binding.
      Type Parameters:
      T - type of value
      Parameters:
      property - not null
      value - may be null
      Returns:
      an immutable context containing only the given property-value binding (never null)
    • of

      public static <T> IContext of(Class<T> clazz, T value)
      Returns an immutable context containing only the given class-value binding.
      Type Parameters:
      T - type of value
      Parameters:
      clazz - not null
      value - may be null
      Returns:
      an immutable context containing only the given class-value binding (never null)
    • with

      public static IContext with(IContext... contexts)
      Returns a new context that combines the given contexts in the specified order.

      The returned context is immutable provided that each of the given contexts is immutable. If some of the given contexts are not immutable, the returned context is neither immutable nor thread-safe.

      Parameters:
      contexts - the contexts to combine
      Returns:
      the combined context (never null)
    • with

      public static IContext with(List<IContext> contexts)
      Returns a new context that combines the given contexts in the specified order.

      The returned context is immutable provided that each of the given contexts is immutable. If some of the given contexts are not immutable, the returned context is neither immutable nor thread-safe.

      Parameters:
      contexts - the contexts to combine
      Returns:
      the combined context (never null)