Package fr.andross.banitem.utils.list
Class Listable
java.lang.Object
fr.andross.banitem.utils.list.Listable
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> List<T>
getAllObjects
(ListType type) This method will give all possibles objects for the given type.static List<BannedItem>
getItems
(BanDatabase database, Object obj, Debug d) Trying to get a list of type If there is any error, this will be debuggedstatic <T> List<T>
Get a list of type.static List<org.bukkit.Material>
getMaterials
(Object obj, Debug d) Trying to get a list of materials If there is any error, this will be debuggedstatic <T> T
This method will try to get an element for the given typestatic List<com.sk89q.worldguard.protection.regions.ProtectedRegion>
getRegionsList
(BanItem pl, Object obj, Debug d, Collection<org.bukkit.World> worlds) Get a list of protected regionsgetSplittedList
(String string) getSplittedList
(List<String> list) Try to get a prepared splited (,) list of string from an objectTrying to get a listable string from an Object.static List<org.bukkit.World>
Trying to get a list of type If there is any error, this will be debuggedstatic <T> List<T>
newList
(T... a) This will create a new (mutable) list from an array
-
Constructor Details
-
Listable
public Listable()
-
-
Method Details
-
getSplittedList
- Parameters:
string
- string to split- Returns:
- a list of splitted string
-
getSplittedList
- Parameters:
list
- list of strings to split- Returns:
- a list containing all strings splitted from another one
-
getStringList
Trying to get a listable string from an Object. Mainly used to extract strings from aConfigurationSection.get(String)
- Parameters:
o
- object to parse- Returns:
- a splitted list of elements in this object
-
getSplittedStringList
Try to get a prepared splited (,) list of string from an object- Parameters:
o
- the object- Returns:
- a prepared splited list of string
-
newList
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 insteadgetItems(BanDatabase, Object, Debug)
,getWorlds(Object, Debug)
, andgetRegionsList(BanItem, Object, Debug, Collection)
,- Type Parameters:
T
- parameter respecting the type class- Parameters:
type
- type of dataobj
- object to get a list fromd
- debugger, returning empty list if null and if there is any error- Returns:
- a list of parsed type
-
getWorlds
Trying to get a list of type If there is any error, this will be debugged- Parameters:
obj
- object to get a list fromd
- 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 fromd
- 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 instanceobj
- object to get a list fromd
- 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 instanceobj
- object to get a list fromd
- debugger, returning empty list if null and if there is any errorworlds
- 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 elementkey
- 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
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
-