Package ch.njol.skript.registrations
Class Converters
java.lang.Object
ch.njol.skript.registrations.Converters
Deprecated.
Contains all registered converters and allows operating with them.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <F,
T> T[] Deprecated.static <F,
T> T Deprecated.Converts an object into one of the given types.static <F,
T> T Deprecated.Converts the given value to the desired type.static <T> T[]
convertArray
(@Nullable Object[] o, Class<? extends T>[] to, Class<T> superType) Deprecated.Converts multiple objects into any of the given classes.static <T> T[]
convertArray
(@Nullable Object[] o, Class<T> to) Deprecated.Converts all entries in the given array to the desired type, usingconvert(Object, Class)
to convert every single value.static boolean
converterExists
(Class<?> from, Class<?> to) Deprecated.Tests whether a converter between the given classes exists.static boolean
converterExists
(Class<?> from, Class<?>... to) Deprecated.static <T> T[]
convertStrictly
(Object[] original, Class<T> to) Deprecated.Strictly converts an array to a non-null array of the specified class.static <T> T
convertStrictly
(Object original, Class<T> to) Deprecated.Strictly converts an object to the specified classstatic <F,
T> T[] convertUnsafe
(F[] from, Class<?> to, Converter<? super F, ? extends T> conv) Deprecated.static void
Deprecated.static <F,
T> @Nullable Converter <? super F, ? extends T> getConverter
(Class<F> from, Class<T> to) Deprecated.Gets a converterstatic <F,
T> @Nullable Converter.ConverterInfo <? super F, ? extends T> getConverterInfo
(Class<F> from, Class<T> to) Deprecated.Gets a converter that has been registered before.static <F,
T> List <Converter.ConverterInfo<?, ?>> Deprecated.static <F,
T> void registerConverter
(Class<F> from, Class<T> to, Converter<F, T> converter) Deprecated.Registers a converter.static <F,
T> void registerConverter
(Class<F> from, Class<T> to, Converter<F, T> converter, int options) Deprecated.
-
Method Details
-
getConverters
Deprecated. -
registerConverter
Deprecated.Registers a converter.- Parameters:
from
- Type that the converter converts from.to
- Type that the converter converts to.converter
- Actual converter.
-
registerConverter
public static <F,T> void registerConverter(Class<F> from, Class<T> to, Converter<F, T> converter, int options) Deprecated. -
createMissingConverters
public static void createMissingConverters()Deprecated. -
convert
Deprecated.Converts the given value to the desired type. If you want to convert multiple values of the same type you should usegetConverter(Class, Class)
to get a converter to convert the values.- Parameters:
o
-to
-- Returns:
- The converted value or null if no converter exists or the converter returned null for the given value.
-
convert
Deprecated.Converts an object into one of the given types.This method does not convert the object if it is already an instance of any of the given classes.
- Parameters:
o
-to
-- Returns:
- The converted object
-
convertArray
Deprecated.Converts all entries in the given array to the desired type, usingconvert(Object, Class)
to convert every single value. If you want to convert an array of values of a known type, consider usingconvert(Object[], Class, Converter)
for much better performance.- Parameters:
o
-to
-- Returns:
- A T[] array without null elements
-
convertArray
public static <T> T[] convertArray(@Nullable @Nullable Object[] o, Class<? extends T>[] to, Class<T> superType) Deprecated.Converts multiple objects into any of the given classes.- Parameters:
o
-to
-superType
- The component type of the returned array- Returns:
- The converted array
-
convertStrictly
Deprecated.Strictly converts an array to a non-null array of the specified class. Uses registeredConverters
to convert.- Parameters:
original
- The array to convertto
- What to convertoriginal
to- Returns:
original
converted to an array ofto
- Throws:
ClassCastException
- if one oforiginal
's elements cannot be converted to ato
-
convertStrictly
Deprecated.Strictly converts an object to the specified class- Parameters:
original
- The object to convertto
- What to convertoriginal
to- Returns:
original
converted to ato
- Throws:
ClassCastException
- iforiginal
could not be converted to ato
-
converterExists
Deprecated.Tests whether a converter between the given classes exists.- Parameters:
from
-to
-- Returns:
- Whether a converter exists
-
converterExists
Deprecated. -
getConverter
@Nullable public static <F,T> @Nullable Converter<? super F,? extends T> getConverter(Class<F> from, Class<T> to) Deprecated.Gets a converter- Parameters:
from
-to
-- Returns:
- the converter or null if none exist
-
getConverterInfo
@Nullable public static <F,T> @Nullable Converter.ConverterInfo<? super F,? extends T> getConverterInfo(Class<F> from, Class<T> to) Deprecated.Gets a converter that has been registered before.- Parameters:
from
-to
-- Returns:
- The converter info or null if no converters were found.
-
convertUnsafe
public static <F,T> T[] convertUnsafe(F[] from, Class<?> to, Converter<? super F, ? extends T> conv) Deprecated.- Parameters:
from
-to
-conv
-- Returns:
- The converted array
- Throws:
ArrayStoreException
- if the given class is not a superclass of all objects returned by the converter
-
convert
Deprecated.
-
Converters