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 multipleContext
instances, usually stored together in aSet
.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
Contextual
s circumstance within a given world would have key of "world" and a value equal to the name of the world.Context
is immutable. ThesetValue(String)
inherited fromMap.Entry
is not supported.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DIMENSION_KEY
static java.lang.String
LOCAL_HOST_KEY
static java.lang.String
LOCAL_IP_KEY
static java.lang.String
LOCAL_PORT_KEY
static java.lang.String
REMOTE_IP_KEY
static java.lang.String
USER_KEY
static java.lang.String
WORLD_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 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 valuesjava.lang.String
toString()
-
-
-
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:
getKey
in 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:
getValue
in 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:
setValue
in 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:
equals
in interfacejava.util.Map.Entry<java.lang.String,java.lang.String>
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfacejava.util.Map.Entry<java.lang.String,java.lang.String>
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-