Class Context

java.lang.Object
org.eclipse.handly.context.Context
All Implemented Interfaces:
IContext

public final class Context extends 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.
  • Constructor Details

    • Context

      public Context()
  • Method Details

    • 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(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(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(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)