Package ch.njol.skript.classes
Class Converter.ConverterUtils
java.lang.Object
ch.njol.skript.classes.Converter.ConverterUtils
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <F, T> Converter<?,T>
createDoubleInstanceofConverter(Converter.ConverterInfo<F,?> conv, Class<T> to)
static <F, T> Converter<?,T>
createDoubleInstanceofConverter(Class<F> from, Converter<F,?> conv, Class<T> to)
Wraps a converter.static <F, T> Converter<?,T>
createInstanceofConverter(Converter.ConverterInfo<F,T> conv)
static <F, T> Converter<F,T>
createInstanceofConverter(Converter<F,?> conv, Class<T> to)
Wraps a converter in a filter that will only accept conversion results of given type.static <F, T> Converter<?,T>
createInstanceofConverter(Class<F> from, Converter<F,T> conv)
-
Constructor Details
-
ConverterUtils
public ConverterUtils()
-
-
Method Details
-
createInstanceofConverter
public static <F, T> Converter<?,T> createInstanceofConverter(Converter.ConverterInfo<F,T> conv) -
createInstanceofConverter
-
createInstanceofConverter
Wraps a converter in a filter that will only accept conversion results of given type. All other results are replaced with nulls.- Parameters:
conv
- Converter to wrap.to
- Accepted return type of the converter.- Returns:
- The wrapped converter.
-
createDoubleInstanceofConverter
public static <F, T> Converter<?,T> createDoubleInstanceofConverter(Converter.ConverterInfo<F,?> conv, Class<T> to) -
createDoubleInstanceofConverter
public static <F, T> Converter<?,T> createDoubleInstanceofConverter(Class<F> from, Converter<F,?> conv, Class<T> to)Wraps a converter. When values given to the wrapper converter are not of accepted type, it will not be called; instead, a null is returned. When it returns a value that is not of accepted type, the wrapped converter will return null instead.- Parameters:
from
- Accepted type of input.conv
- Converter to wrap.to
- Accepted type of output.- Returns:
- A wrapped converter.
-