public class LazyMetadataValue extends MetadataValueAdapter
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.
限定符和类型 | 类和说明 |
---|---|
static class |
LazyMetadataValue.CacheStrategy
Describes possible caching strategies for metadata.
|
owningPlugin
限定符 | 构造器和说明 |
---|---|
protected |
LazyMetadataValue(Plugin owningPlugin)
Protected special constructor used by FixedMetadataValue to bypass
standard setup.
|
|
LazyMetadataValue(Plugin owningPlugin,
java.util.concurrent.Callable<java.lang.Object> lazyValue)
Initialized a LazyMetadataValue object with the default
CACHE_AFTER_FIRST_EVAL cache strategy.
|
|
LazyMetadataValue(Plugin owningPlugin,
LazyMetadataValue.CacheStrategy cacheStrategy,
java.util.concurrent.Callable<java.lang.Object> lazyValue)
Initializes a LazyMetadataValue object with a specific cache strategy.
|
限定符和类型 | 方法和说明 |
---|---|
void |
invalidate()
Invalidates this metadata item, forcing it to recompute when next
accessed.
|
java.lang.Object |
value()
Fetches the value of this metadata item.
|
asBoolean, asByte, asDouble, asFloat, asInt, asLong, asShort, asString, getOwningPlugin
public LazyMetadataValue(Plugin owningPlugin, java.util.concurrent.Callable<java.lang.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, java.util.concurrent.Callable<java.lang.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.protected LazyMetadataValue(Plugin owningPlugin)
owningPlugin
- the owning pluginpublic java.lang.Object value()
MetadataValue
public void invalidate()
MetadataValue