Selective merge of commanding branch.

This commit is contained in:
MattBDev
2019-10-23 12:58:36 -04:00
parent 8768085479
commit fd408c64ed
17 changed files with 259 additions and 227 deletions

View File

@ -1,5 +1,8 @@
package com.sk89q.worldedit.entity;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface Metadatable {
/**
@ -13,36 +16,43 @@ public interface Metadatable {
<T> T getAndSetMeta(String key, T value);
/**
* Checks if the object contains any metadata.
*
* @return {@code true} if there is metadata set for the object
*/
boolean hasMeta();
/**
* Get the metadata for a key.
* Gets the metadata value to which the specified key is mapped,
* or {@code null} if the key is not set.
*
* @param <V>
* @param key
* @return
* @param key the key of the metadata value to retrieve
* @return the value of the metadata or {@code null} if none exists
*/
<V> V getMeta(String key);
/**
* Get the metadata for a specific key (or return the default provided)
* Gets the metadata value to which the specified key is mapped,
* or the default value if no metadata exists for the key.
*
* @param key
* @param def
* @param <V>
* @return
* @param key the key of the metadata value to retrieve
* @param defaultValue the value to return if there is no metadata for the given key
* @return the metadata value for the key, if present; else the default value
*/
default <V> V getMeta(String key, V def) {
@NotNull
default <V> V getMeta(String key, @NotNull V defaultValue) {
V value = (V) getMeta(key);
return value == null ? def : value; }
return value == null ? defaultValue : value; }
/**
* Delete the metadata for a key.
* - metadata is session only
* - deleting other plugin's metadata may cause issues
* Deletes the given metadata key from object. Do not delete metadata set by another plugin
* unless you know what you are doing.
*
* @param key
* @param key the key identifying the metadata to remove.
* @return the previous value associated with they given key
*/
@Nullable
<V> V deleteMeta(String key);
final class METADATA_KEYS {