|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.bukkit.metadata.LazyMetadataValue
public class LazyMetadataValue
The LazyMetadataValue class implements a type of metadata that is not computed until another plugin asks for it.
By making metadata values lazy, no computation is done by the providing plugin until absolutely necessary (if ever).
Additionally, LazyMetadataValue objects cache their values internally unless overridden by a LazyMetadataValue.CacheStrategy
or invalidated at the individual or plugin level. Once invalidated, the LazyMetadataValue will recompute its value
when asked.
Nested Class Summary | |
---|---|
static class |
LazyMetadataValue.CacheStrategy
Describes possible caching strategies for metadata. |
Constructor Summary | |
---|---|
LazyMetadataValue(Plugin owningPlugin,
Callable<Object> lazyValue)
Initialized a LazyMetadataValue object with the default CACHE_AFTER_FIRST_EVAL cache strategy. |
|
LazyMetadataValue(Plugin owningPlugin,
LazyMetadataValue.CacheStrategy cacheStrategy,
Callable<Object> lazyValue)
Initializes a LazyMetadataValue object with a specific cache strategy. |
Method Summary | |
---|---|
boolean |
asBoolean()
Attempts to convert the value of this metadata item into a boolean. |
byte |
asByte()
Attempts to convert the value of this metadata item into a byte. |
double |
asDouble()
Attempts to convert the value of this metadata item into a double. |
float |
asFloat()
Attempts to convert the value of this metadata item into a float. |
int |
asInt()
Attempts to convert the value of this metadata item into an int. |
long |
asLong()
Attempts to convert the value of this metadata item into a long. |
short |
asShort()
Attempts to convert the value of this metadata item into a short. |
String |
asString()
Attempts to convert the value of this metadata item into a string. |
Plugin |
getOwningPlugin()
Returns the Plugin that created this metadata item. |
void |
invalidate()
Invalidates this metadata item, forcing it to recompute when next accessed. |
Object |
value()
Fetches the value of this metadata item. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LazyMetadataValue(Plugin owningPlugin, Callable<Object> lazyValue)
owningPlugin
- the Plugin
that created this metadata value.lazyValue
- the lazy value assigned to this metadata value.public LazyMetadataValue(Plugin owningPlugin, LazyMetadataValue.CacheStrategy cacheStrategy, Callable<Object> lazyValue)
owningPlugin
- the Plugin
that created this metadata value.cacheStrategy
- determines the rules for caching this metadata value.lazyValue
- the lazy value assigned to this metadata value.Method Detail |
---|
public Plugin getOwningPlugin()
MetadataValue
Plugin
that created this metadata item.
getOwningPlugin
in interface MetadataValue
public Object value()
MetadataValue
value
in interface MetadataValue
public int asInt()
MetadataValue
asInt
in interface MetadataValue
public float asFloat()
MetadataValue
asFloat
in interface MetadataValue
public double asDouble()
MetadataValue
asDouble
in interface MetadataValue
public long asLong()
MetadataValue
asLong
in interface MetadataValue
public short asShort()
MetadataValue
asShort
in interface MetadataValue
public byte asByte()
MetadataValue
asByte
in interface MetadataValue
public boolean asBoolean()
MetadataValue
asBoolean
in interface MetadataValue
public String asString()
MetadataValue
asString
in interface MetadataValue
public void invalidate()
MetadataValue
invalidate
in interface MetadataValue
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |