Class StringData

  • All Implemented Interfaces:
    Annoyable
    Direct Known Subclasses:
    EntityData

    public class StringData
    extends Data<java.lang.String>
    A data class for storing and retrieving string data from SQL databases
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static @NotNull java.lang.String TARGET_COLUMN
      The primary target column name
      boolean useCache
      Whether to use the cache for this data
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      @Nullable java.lang.String get​(@NotNull java.lang.String key)
      Get the data value for the given key
      boolean remove​(@NotNull java.lang.String key)
      Remove the data value with the given key
      protected boolean set​(@NotNull java.lang.String key, @NotNull java.lang.String value)
      Set the data value for the given key.
      @NotNull StringData useCache​(@Nullable java.lang.Boolean useCache)
      Whether to use the cache for this data (if caching is enabled in the storage config)
      Defaults to DataOptions.useCacheDefault
      • Methods inherited from class xyz.srnyx.javautilities.parents.Stringable

        toString, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • TARGET_COLUMN

        @NotNull
        public static final @NotNull java.lang.String TARGET_COLUMN
        The primary target column name
        See Also:
        Constant Field Values
      • useCache

        public boolean useCache
        Whether to use the cache for this data
    • Constructor Detail

      • StringData

        public StringData​(@NotNull
                          @NotNull AnnoyingPlugin plugin,
                          @NotNull
                          @NotNull java.lang.String table,
                          @NotNull
                          @NotNull java.lang.String string)
        Construct a new StringData for the given string
        Parameters:
        plugin - Data.plugin
        table - table
        string - Data.target
      • StringData

        public StringData​(@NotNull
                          @NotNull AnnoyingPlugin plugin,
                          @NotNull
                          @NotNull org.bukkit.OfflinePlayer player)
        Construct a new StringData for the given OfflinePlayer
        This uses the same table used for EntityData (EntityData.TABLE_NAME) and the player's UUID as the target
        Parameters:
        plugin - Data.plugin
        player - the player to get/store the data for
    • Method Detail

      • useCache

        @NotNull
        public @NotNull StringData useCache​(@Nullable
                                            @Nullable java.lang.Boolean useCache)
        Whether to use the cache for this data (if caching is enabled in the storage config)
        Defaults to DataOptions.useCacheDefault
        Parameters:
        useCache - the new value or null to use DataOptions.useCacheDefault
        Returns:
        this for chaining
      • get

        @Nullable
        public @Nullable java.lang.String get​(@NotNull
                                              @NotNull java.lang.String key)
        Description copied from class: Data
        Get the data value for the given key
        Specified by:
        get in class Data<java.lang.String>
        Parameters:
        key - the key to get the data value for
        Returns:
        the data value, or null if not found
      • set

        protected boolean set​(@NotNull
                              @NotNull java.lang.String key,
                              @NotNull
                              @NotNull java.lang.String value)
        Description copied from class: Data
        Set the data value for the given key. If the key already exists, it will be overwritten
        Specified by:
        set in class Data<java.lang.String>
        Parameters:
        key - the key to set the data value for
        value - the data value to set
        Returns:
        true if the data value was set successfully, false otherwise
      • remove

        public boolean remove​(@NotNull
                              @NotNull java.lang.String key)
        Description copied from class: Data
        Remove the data value with the given key
        Specified by:
        remove in class Data<java.lang.String>
        Parameters:
        key - the key to remove the data value for
        Returns:
        true if the data value was removed successfully, false otherwise