Class DataCollection


  • public class DataCollection
    extends Object
    Store and parser arguments for better CommandExecutor usage.
    • Constructor Detail

      • DataCollection

        public DataCollection​(@NotNull
                              DataConverter<?>[] dataConverters)
        Initialize the DataCollection with fixed size.
        Parameters:
        dataConverters - the data converters
    • Method Detail

      • register

        public static void register​(Plugin plugin,
                                    DataConverter<?> dataConverter,
                                    DataCollection.BufferGetter bufferGetter)
        Register the getter of the buffer
        Parameters:
        plugin - the plugin
        dataConverter - the buffer data converter
        bufferGetter - the getter of the buffer
      • unregister

        public static void unregister​(Plugin plugin)
        Unregister the getter of the buffers by plugin
        Parameters:
        plugin - the plugin
      • unregisterAll

        public static boolean unregisterAll()
        Unregister all the getter of the buffers
        Returns:
        true if there are some getter of the buffers not belonging to MainPlugin not been unregistered, false otherwise
      • get

        public @NonNull String get()
        Get String argument in order
        Returns:
        the String argument in order
        Throws:
        NullPointerException - if the value is null
      • getInt

        public int getInt()
        Get int argument in order
        Returns:
        the int argument in order
        Throws:
        NullPointerException - if the value is null
      • getDouble

        public double getDouble()
        Get double argument in order
        Returns:
        the double argument in order
        Throws:
        NullPointerException - if the value is null
      • getBoolean

        public boolean getBoolean()
        Get boolean argument in order
        Returns:
        the boolean argument in order
        Throws:
        NullPointerException - if the value is null
      • getLong

        public long getLong()
        Get long argument in order
        Returns:
        the long argument in order
        Throws:
        NullPointerException - if the value is null
      • getPlugin

        public @NonNull Plugin getPlugin()
        Get Plugin argument in order
        Returns:
        the Plugin argument in order
        Throws:
        NullPointerException - if the value is null
      • getCommand

        public @NonNull Command getCommand()
        Get Command argument in order
        Returns:
        the Command argument in order
      • getOrDefault

        @Contract("_,!null->!null")
        public <T> T getOrDefault​(Class<T> cls,
                                  T t)
        Get buffer element
        Type Parameters:
        T - the buffer elements' type
        Parameters:
        cls - the buffer elements' class
        t - the default value
        Returns:
        the buffer element
        Throws:
        UnsupportedOperationException - if the buffer is not registered
      • getOrDefault

        @Contract("_,_,!null->!null")
        public <T> T getOrDefault​(Class<T> cls,
                                  int index,
                                  T t)
        Get buffer element
        Type Parameters:
        T - the buffer elements' type
        Parameters:
        cls - the buffer elements' class
        t - the default value
        index - the buffer element index
        Returns:
        the buffer element
        Throws:
        UnsupportedOperationException - if the buffer is not registered
      • get

        @Nullable
        public <T> T get​(Class<T> c)
        Get buffer element
        Type Parameters:
        T - the buffer elements' type
        Parameters:
        c - the buffer elements' class
        Returns:
        the buffer element
        Throws:
        UnsupportedOperationException - if the buffer is not registered
      • get

        @Nullable
        public <T> T get​(Class<T> c,
                         int index)
        Get buffer element
        Type Parameters:
        T - the buffer elements' type
        Parameters:
        index - the buffer element index
        c - the buffer elements' class
        Returns:
        the buffer element
        Throws:
        UnsupportedOperationException - if the buffer is not registered