Class Contexts


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

      Fields 
      Modifier and Type Field Description
      static IContext EMPTY_CONTEXT
      The empty context (immutable).
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> IContext of​(java.lang.Class<T> clazz, T value)
      Returns an immutable context containing only the given class-value binding.
      static <T> IContext of​(Property<T> property, T value)
      Returns an immutable context containing only the given property-value binding.
      static IContext with​(java.util.List<IContext> contexts)
      Returns a new context that combines the given contexts in the specified order.
      static IContext with​(IContext... contexts)
      Returns a new context that combines the given contexts in the specified order.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • EMPTY_CONTEXT

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

      • 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​(java.lang.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​(java.util.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)