Class Context
- java.lang.Object
-
- org.spongepowered.api.service.context.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 aContextual.A
Contextual's overall "context" is made up multipleContextinstances, usually stored together in aSet.Any single
Contextattribute 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.Contextis immutable. ThesetValue(String)inherited fromMap.Entryis not supported.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDIMENSION_KEYstatic java.lang.StringLOCAL_HOST_KEYstatic java.lang.StringLOCAL_IP_KEYstatic java.lang.StringLOCAL_PORT_KEYstatic java.lang.StringREMOTE_IP_KEYstatic java.lang.StringUSER_KEYstatic java.lang.StringWORLD_KEY
-
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 booleanequals(java.lang.Object other)java.lang.StringgetKey()Gets the context key.java.lang.StringgetValue()Gets the context value.inthashCode()java.lang.StringsetValue(java.lang.String value)Deprecated.Context does not support changing the valuesjava.lang.StringtoString()
-
-
-
Field Detail
-
USER_KEY
public static final java.lang.String USER_KEY
- See Also:
- Constant Field Values
-
WORLD_KEY
public static final java.lang.String WORLD_KEY
- See Also:
- Constant Field Values
-
DIMENSION_KEY
public static final java.lang.String DIMENSION_KEY
- See Also:
- Constant Field Values
-
REMOTE_IP_KEY
public static final java.lang.String REMOTE_IP_KEY
- See Also:
- Constant Field Values
-
LOCAL_HOST_KEY
public static final java.lang.String LOCAL_HOST_KEY
- See Also:
- Constant Field Values
-
LOCAL_IP_KEY
public static final java.lang.String LOCAL_IP_KEY
- See Also:
- Constant Field Values
-
LOCAL_PORT_KEY
public static final java.lang.String LOCAL_PORT_KEY
- See Also:
- Constant Field Values
-
-
Method Detail
-
getKey
public java.lang.String getKey()
Gets the context key.- Specified by:
getKeyin interfacejava.util.Map.Entry<java.lang.String,java.lang.String>- Returns:
- The key
-
getValue
public java.lang.String getValue()
Gets the context value.- Specified by:
getValuein interfacejava.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:
setValuein interfacejava.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:
equalsin interfacejava.util.Map.Entry<java.lang.String,java.lang.String>- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfacejava.util.Map.Entry<java.lang.String,java.lang.String>- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-