Class Context

  • All Implemented Interfaces:
    java.util.Map.Entry<java.lang.String,​java.lang.String>

    public final class Context
    extends java.lang.Object
    implements java.util.Map.Entry<java.lang.String,​java.lang.String>
    Encapsulates a single attribute about the state or circumstances of a Contextual.

    A Contextual's overall "context" is made up multiple Context instances, usually stored together in a Set.

    Any single Context attribute is made up of a key and a value. The key represents the type of context, and the value is just that, the value associated with the key. Some common/shared keys are expressed as static fields on this class for convenience.

    For example, a context encapsulating a Contextuals circumstance within a given world would have key of "world" and a value equal to the name of the world.

    Context is immutable. The setValue(String) inherited from Map.Entry is not supported.

    • Constructor Summary

      Constructors 
      Constructor Description
      Context​(java.lang.String key, java.lang.String value)
      Create a new context instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object other)  
      java.lang.String getKey()
      Gets the context key.
      java.lang.String getValue()
      Gets the context value.
      int hashCode()  
      java.lang.String setValue​(java.lang.String value)
      Deprecated.
      Context does not support changing the values
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Context

        public Context​(java.lang.String key,
                       java.lang.String value)
        Create a new context instance.
        Parameters:
        key - Context key. Must not be null.
        value - Context value. Must not be null.
    • Method Detail

      • getKey

        public java.lang.String getKey()
        Gets the context key.
        Specified by:
        getKey in interface java.util.Map.Entry<java.lang.String,​java.lang.String>
        Returns:
        The key
      • getValue

        public java.lang.String getValue()
        Gets the context value.
        Specified by:
        getValue in interface java.util.Map.Entry<java.lang.String,​java.lang.String>
        Returns:
        The value
      • setValue

        @Deprecated
        public java.lang.String setValue​(java.lang.String value)
        Deprecated.
        Context does not support changing the values
        Specified by:
        setValue in interface java.util.Map.Entry<java.lang.String,​java.lang.String>
        Parameters:
        value - The value
        Returns:
        Nothing
        Throws:
        java.lang.UnsupportedOperationException - Contexts are immutable
      • equals

        public boolean equals​(java.lang.Object other)
        Specified by:
        equals in interface java.util.Map.Entry<java.lang.String,​java.lang.String>
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Map.Entry<java.lang.String,​java.lang.String>
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object