Package xyz.srnyx.annoyingapi.data
Class Data<T>
java.lang.Object
xyz.srnyx.javautilities.parents.Stringable
xyz.srnyx.annoyingapi.data.Data<T>
- Type Parameters:
T- the type of target to manage data for
- All Implemented Interfaces:
Annoyable
- Direct Known Subclasses:
ItemData,StringData
public abstract class Data<T>
extends xyz.srnyx.javautilities.parents.Stringable
implements Annoyable
Represents a class that can be used to manage data
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final @NotNull AnnoyingPluginTheplugininstancefinal TThe target to manage data for -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedData(@NotNull AnnoyingPlugin plugin, T target) Construct a newDatafor the given target -
Method Summary
Modifier and TypeMethodDescriptionabstract @Nullable StringGet the data value for the given key@NotNull StringGet the data value for the given key, or the default value if not found@NotNull AnnoyingPluginTheAnnoyingPlugininstancegetOptional(@NotNull String key) Get the data value for the given key as anOptionalbooleanCheck if the data value exists for the given keyabstract booleanRemove the data value with the given keyremoveChain(@NotNull String key) Remove the data value with the given keyprotected voidSend an error message to the consoleprotected abstract booleanSet the data value for the given key.booleanSet the data value for the given key.Set the data value for the given key.Methods inherited from class xyz.srnyx.javautilities.parents.Stringable
toString, toString, toString, toString, toString
-
Field Details
-
plugin
Theplugininstance -
target
The target to manage data for
-
-
Constructor Details
-
Method Details
-
getAnnoyingPlugin
Description copied from interface:AnnoyableTheAnnoyingPlugininstance- Specified by:
getAnnoyingPluginin interfaceAnnoyable- Returns:
- the plugin instance
-
has
Check if the data value exists for the given key- Parameters:
key- the key to check for- Returns:
trueif the data value exists,falseotherwise
-
get
Get the data value for the given key- Parameters:
key- the key to get the data value for- Returns:
- the data value, or null if not found
-
get
Get the data value for the given key, or the default value if not found- Parameters:
key- the key to get the data value fordef- the default value to return if the data value is not found- Returns:
- the data value, or the default value if not found
-
getOptional
Get the data value for the given key as anOptional- Parameters:
key- the key to get the data value for- Returns:
- the data value as an
Optional
-
set
Set the data value for the given key. If the key already exists, it will be overwritten- Parameters:
key- the key to set the data value forvalue- the data value to set- Returns:
trueif the data value was set successfully,falseotherwise
-
set
Set the data value for the given key. If the key already exists, it will be overwritten- Parameters:
key- the key to set the data value forvalue- the data value to set, or null to remove the data value- Returns:
trueif the data value was set successfully,falseotherwise
-
setChain
@NotNull public @NotNull Data<T> setChain(@NotNull @NotNull String key, @Nullable @Nullable Object value) Set the data value for the given key. If the key already exists, it will be overwritten- Parameters:
key- the key to set the data value forvalue- the data value to set, or null to remove the data value- Returns:
- this
Datainstance for chaining
-
remove
Remove the data value with the given key- Parameters:
key- the key to remove the data value for- Returns:
trueif the data value was removed successfully,falseotherwise
-
removeChain
Remove the data value with the given key- Parameters:
key- the key to remove the data value for- Returns:
- this
Datainstance for chaining
-
sendError
Send an error message to the console- Parameters:
action- the action that failedt- theThrowablethat caused the error
-