Class Context

  • All Implemented Interfaces:
    IContext

    public final class Context
    extends java.lang.Object
    implements IContext
    Implementation of IContext that is based on explicit bindings and does not allow re-binding. It is illegal to bind a key that has already been bound.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      class  Context.BindingBuilder<T>
      Associates a value with a key in this context.
    • Constructor Summary

      Constructors 
      Constructor Description
      Context()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> Context.BindingBuilder<T> bind​(java.lang.Class<T> clazz)
      Returns a binding builder for the given class.
      <T> Context.BindingBuilder<T> bind​(Property<T> property)
      Returns a binding builder for the given property.
      boolean containsKey​(java.lang.Class<?> clazz)
      Returns whether this context has a value associated with the given class.
      boolean containsKey​(Property<?> property)
      Returns whether this context has a value associated with the given property.
      <T> T get​(java.lang.Class<T> clazz)
      Returns the context value associated with the given class.
      <T> T get​(Property<T> property)
      Returns the context value associated with the given property.
      • Methods inherited from class java.lang.Object

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

      • Context

        public Context()
    • Method Detail

      • get

        public <T> T get​(Property<T> property)
        Description copied from interface: IContext
        Returns the context value associated with the given property.
        Specified by:
        get in interface IContext
        Parameters:
        property - the property being queried (not null)
        Returns:
        an object corresponding to the given property, or null
      • get

        public <T> T get​(java.lang.Class<T> clazz)
        Description copied from interface: IContext
        Returns the context value associated with the given class.
        Specified by:
        get in interface IContext
        Parameters:
        clazz - the class being queried (not null)
        Returns:
        an object corresponding to the given class, or null
      • containsKey

        public boolean containsKey​(Property<?> property)
        Description copied from interface: IContext
        Returns whether this context has a value associated with the given property.
        Specified by:
        containsKey in interface IContext
        Parameters:
        property - the property being queried (not null)
        Returns:
        true if this context has a value for the given property, and false otherwise
      • containsKey

        public boolean containsKey​(java.lang.Class<?> clazz)
        Description copied from interface: IContext
        Returns whether this context has a value associated with the given class.
        Specified by:
        containsKey in interface IContext
        Parameters:
        clazz - the class being queried (not null)
        Returns:
        true if this context has a value for the given class, and false otherwise
      • bind

        public <T> Context.BindingBuilder<T> bind​(Property<T> property)
        Returns a binding builder for the given property.
        Parameters:
        property - the property to bind (not null)
        Returns:
        a binding builder (never null)
      • bind

        public <T> Context.BindingBuilder<T> bind​(java.lang.Class<T> clazz)
        Returns a binding builder for the given class.
        Parameters:
        clazz - the class to bind (not null)
        Returns:
        a binding builder (never null)