MetadataValueFixedMetadataValuepublic 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.
| Modifier and Type | Class | Description |
|---|---|---|
static class |
LazyMetadataValue.CacheStrategy |
Describes possible caching strategies for metadata.
|
owningPlugin| Modifier | Constructor | Description |
|---|---|---|
protected |
LazyMetadataValue(@NotNull Plugin owningPlugin) |
Protected special constructor used by FixedMetadataValue to bypass
standard setup.
|
|
LazyMetadataValue(@NotNull Plugin owningPlugin,
@NotNull Callable<Object> lazyValue) |
Initialized a LazyMetadataValue object with the default
CACHE_AFTER_FIRST_EVAL cache strategy.
|
|
LazyMetadataValue(@NotNull Plugin owningPlugin,
@NotNull LazyMetadataValue.CacheStrategy cacheStrategy,
@NotNull Callable<Object> lazyValue) |
Initializes a LazyMetadataValue object with a specific cache strategy.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
invalidate() |
Invalidates this metadata item, forcing it to recompute when next
accessed.
|
@Nullable Object |
value() |
Fetches the value of this metadata item.
|
asBoolean, asByte, asDouble, asFloat, asInt, asLong, asShort, asString, getOwningPluginpublic LazyMetadataValue(@NotNull
@NotNull Plugin owningPlugin,
@NotNull
@NotNull Callable<Object> lazyValue)
owningPlugin - the Plugin that created this metadata
value.lazyValue - the lazy value assigned to this metadata value.public LazyMetadataValue(@NotNull
@NotNull Plugin owningPlugin,
@NotNull
@NotNull LazyMetadataValue.CacheStrategy cacheStrategy,
@NotNull
@NotNull 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.protected LazyMetadataValue(@NotNull
@NotNull Plugin owningPlugin)
owningPlugin - the owning plugin@Nullable public @Nullable Object value()
MetadataValuepublic void invalidate()
MetadataValueCopyright © 2020. All rights reserved.