Package org.bukkit.metadata

# Class MetadataValueAdapter

java.lang.Object
org.bukkit.metadata.MetadataValueAdapter

All Implemented Interfaces:
  `MetadataValue`

Direct Known Subclasses:
  `LazyMetadataValue`

public abstract class MetadataValueAdapter extends Object implements MetadataValue
Optional base class for facilitating MetadataValue implementations.

This provides all the conversion functions for MetadataValue so that writing an implementation of MetadataValue is as simple as implementing value() and invalidate().

## Field Summary

Fields
Modifier and Type
Field
Description
`protected final WeakReference<Plugin>`
`owningPlugin`

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`MetadataValueAdapter(@NotNull Plugin owningPlugin)`

## Method Summary

Modifier and Type
Method
Description
`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.
`@NotNull String`
`asString()`
Attempts to convert the value of this metadata item into a string.
`@Nullable Plugin`
`getOwningPlugin()`
Returns the `Plugin` that created this metadata item.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.bukkit.metadata.MetadataValue

`invalidate, value`

## Field Details

### owningPlugin

protected final WeakReference<Plugin> owningPlugin

## Constructor Details

### MetadataValueAdapter

protected MetadataValueAdapter(@NotNull @NotNull Plugin owningPlugin)

## Method Details

### getOwningPlugin

@Nullable public @Nullable Plugin getOwningPlugin()
Description copied from interface: `MetadataValue`
Returns the `Plugin` that created this metadata item.

Specified by:
  `getOwningPlugin` in interface `MetadataValue`
Returns:
  the plugin that owns this metadata value. Could be null if the plugin was already unloaded.

### asInt

public int asInt()
Description copied from interface: `MetadataValue`
Attempts to convert the value of this metadata item into an int.

Specified by:
  `asInt` in interface `MetadataValue`
Returns:
  the value as an int.

### asFloat

public float asFloat()
Description copied from interface: `MetadataValue`
Attempts to convert the value of this metadata item into a float.

Specified by:
  `asFloat` in interface `MetadataValue`
Returns:
  the value as a float.

### asDouble

public double asDouble()
Description copied from interface: `MetadataValue`
Attempts to convert the value of this metadata item into a double.

Specified by:
  `asDouble` in interface `MetadataValue`
Returns:
  the value as a double.

### asLong

public long asLong()
Description copied from interface: `MetadataValue`
Attempts to convert the value of this metadata item into a long.

Specified by:
  `asLong` in interface `MetadataValue`
Returns:
  the value as a long.

### asShort

public short asShort()
Description copied from interface: `MetadataValue`
Attempts to convert the value of this metadata item into a short.

Specified by:
  `asShort` in interface `MetadataValue`
Returns:
  the value as a short.

### asByte

public byte asByte()
Description copied from interface: `MetadataValue`
Attempts to convert the value of this metadata item into a byte.

Specified by:
  `asByte` in interface `MetadataValue`
Returns:
  the value as a byte.

### asBoolean

public boolean asBoolean()
Description copied from interface: `MetadataValue`
Attempts to convert the value of this metadata item into a boolean.

Specified by:
  `asBoolean` in interface `MetadataValue`
Returns:
  the value as a boolean.

### asString

@NotNull public @NotNull String asString()
Description copied from interface: `MetadataValue`
Attempts to convert the value of this metadata item into a string.

Specified by:
  `asString` in interface `MetadataValue`
Returns:
  the value as a string.