Class Listable

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

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

    • Listable

      public Listable()
  • Method Details

    • getSplittedList

      @NotNull public static List<String> getSplittedList(@NotNull String string)
      Parameters:
      string - string to split
      Returns:
      a list of splitted string
    • getSplittedList

      @NotNull public static List<String> getSplittedList(@Nullable List<String> list)
      Parameters:
      list - list of strings to split
      Returns:
      a list containing all strings splitted from another one
    • getStringList

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

      @NotNull public static List<String> getSplittedStringList(@Nullable Object o)
      Try to get a prepared splited (,) list of string from an object
      Parameters:
      o - the object
      Returns:
      a prepared splited list of string
    • newList

      @SafeVarargs @NotNull public static <T> 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> List<T> getList(@NotNull ListType type, @NotNull Object obj, @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 List<org.bukkit.World> getWorlds(@NotNull Object obj, @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 List<org.bukkit.Material> getMaterials(@NotNull Object obj, @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 List<BannedItem> getItems(@NotNull BanDatabase database, @NotNull Object obj, @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 List<com.sk89q.worldguard.protection.regions.ProtectedRegion> getRegionsList(@NotNull BanItem pl, @NotNull Object obj, @Nullable Debug d, @NotNull Collection<org.bukkit.World> worlds)
      Get a list of protected regions
      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 ListType type, @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> List<T> getAllObjects(@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