Class Listable

java.lang.Object
fr.andross.banitem.utils.list.Listable

public abstract class Listable extends Object
A powerful listable class which will attempt to create List object from given data. Mainly used to load configurations.
Version:
3.1
Author:
Andross
  • Method Details

    • splitToList

      @NotNull public static @NotNull List<String> splitToList(@NotNull @NotNull String string)
      Split a string into a list of string, based on ',' character. Each item will be trimmed.
      Parameters:
      string - the string to split
      Returns:
      the string split into a list of multiple value, separated by ',' character
    • splitToList

      @NotNull public static @NotNull List<String> splitToList(@Nullable @Nullable List<String> list)
      Split each element in the list into a list of string, based on ',' character. Each item will be trimmed.
      Parameters:
      list - the string to split
      Returns:
      list of all elements split by ',' character
    • getStringList

      @NotNull public static @NotNull List<String> getStringList(@Nullable @Nullable Object o)
      Trying to get a list of string from an Object. Mainly used to extract strings from a ConfigurationSection.get(String)
      Parameters:
      o - object to parse
      Returns:
      a list of elements in this object
    • getSplitStringList

      @NotNull public static @NotNull List<String> getSplitStringList(@Nullable @Nullable Object o)
      Get a list of string based on each elements split with ',' character, based on the type of the object (string, list, array).
      Parameters:
      o - the object
      Returns:
      a list of all elements split with ',' character
    • newList

      @SafeVarargs @NotNull public static <T> @NotNull List<T> newList(@NotNull T... a)
      This will create a new (mutable) list from an array.
      Type Parameters:
      T - parameter
      Parameters:
      a - elements
      Returns:
      a mutable list of elements
    • getList

      @NotNull public static <T> @NotNull List<T> getList(@NotNull @NotNull ListType type, @NotNull @NotNull Object obj, @Nullable @Nullable Debug d)
      Get a list of type. This should not be used for Items, World nor Regions. Use instead getItems(BanDatabase, Object, Debug), getWorlds(Object, Debug), and getRegionsList(BanItem, Object, Debug, Collection),
      Type Parameters:
      T - parameter respecting the type class
      Parameters:
      type - type of data
      obj - object to get a list from
      d - debugger, returning empty list if null and if there is any error
      Returns:
      a list of parsed type
    • getWorlds

      @NotNull public static @NotNull List<org.bukkit.World> getWorlds(@NotNull @NotNull Object obj, @Nullable @Nullable Debug d)
      Trying to get a list of type. If there is any error, this will be debugged.
      Parameters:
      obj - object to get a list from
      d - debugger, returning empty list if null and if there is any error
      Returns:
      a list of parsed type
    • getMaterials

      @NotNull public static @NotNull List<org.bukkit.Material> getMaterials(@NotNull @NotNull Object obj, @Nullable @Nullable Debug d)
      Trying to get a list of materials. If there is any error, this will be debugged.
      Parameters:
      obj - object to get a list from
      d - debugger, returning empty list if null and if there is any error
      Returns:
      a list of parsed type
    • getItems

      @NotNull public static @NotNull List<BannedItem> getItems(@NotNull @NotNull BanDatabase database, @NotNull @NotNull Object obj, @Nullable @Nullable Debug d)
      Trying to get a list of type. If there is any error, this will be debugged.
      Parameters:
      database - the current database instance
      obj - object to get a list from
      d - debugger, returning empty list if null and if there is any error
      Returns:
      a list of items
    • getRegionsList

      @NotNull public static @NotNull List<com.sk89q.worldguard.protection.regions.ProtectedRegion> getRegionsList(@NotNull @NotNull BanItem pl, @NotNull @NotNull Object obj, @Nullable @Nullable Debug d, @NotNull @NotNull Collection<org.bukkit.World> worlds)
      Get a list of protected regions (WorldGuard).
      Parameters:
      pl - the plugin instance
      obj - object to get a list from
      d - debugger, returning empty list if null and if there is any error
      worlds - list of worlds where to get the regions
      Returns:
      a list of regions
    • getObject

      @Nullable public static <T> T getObject(@NotNull @NotNull ListType type, @NotNull @NotNull String key) throws IllegalArgumentException
      This method will try to get an element for the given type.
      Type Parameters:
      T - parameter
      Parameters:
      type - type of the element
      key - object that should be get from this type
      Returns:
      an object of type, null if not found
      Throws:
      IllegalArgumentException - for any Enum non matches
    • getAllObjects

      @NotNull public static <T> @NotNull List<T> getAllObjects(@NotNull @NotNull ListType type)
      This method will give all possibles objects for the given type.
      Type Parameters:
      T - parameter of the type
      Parameters:
      type - type to get
      Returns:
      list of all elements for the given type