Class BazaarContext.Builder

  • Enclosing interface:
    BazaarContext

    public static final class BazaarContext.Builder
    extends java.lang.Object
    A fluent builder of BazaarContexts.
    Author:
    Christian W. Damus
    • Method Detail

      • empty

        public static BazaarContext.Builder empty()
        Creates a new empty context builder.
        Returns:
        an initially empty builder
      • with

        public static BazaarContext.Builder with​(java.util.Map<java.lang.String,​?> values)
        Creates a new context builder with the given initial values.
        Parameters:
        values - initial context values
        Returns:
        an initialized builder
      • put

        public <T> BazaarContext.Builder put​(java.lang.Class<T> key,
                                             T value)
        Adds a context value of the given type.
        Type Parameters:
        T - the value type
        Parameters:
        key - the context value's type
        value - the context value
        Returns:
        this builder
      • add

        public BazaarContext.Builder add​(java.lang.Object value)
        Adds a self-typed context value.
        Parameters:
        value - the context value to add
        Returns:
        this builder
        Throws:
        java.lang.NullPointerException - if the value is null
        See Also:
        put(Class, Object)
      • put

        public BazaarContext.Builder put​(java.lang.String name,
                                         java.lang.Object value)
        Adds a context value for the given name, such as might be used with named injection.
        Parameters:
        name - the context value's name
        value - the context value
        Returns:
        this builder
        See Also:
        Named
      • build

        public BazaarContext build()
        Create the bazaar context. Further updates to the builder will have no effect on the resulting context.
        Returns:
        the bazaar context