Package ninja.leaping.configurate
Class Types
java.lang.Object
ninja.leaping.configurate.Types
public final class Types extends Object
Contains functions useful for performing configuration type conversions.
The naming scheme is as follows:
asmethods attempt to convert the data passed to the appropriate typestrictAsmethods will only return values if the input value is already of an appropriate type
-
Method Summary
Modifier and Type Method Description static @Nullable BooleanasBoolean(@Nullable Object value)Attempts to convertvalueto aBoolean.static @Nullable DoubleasDouble(@Nullable Object value)Attempts to convertvalueto aDouble.static @Nullable FloatasFloat(@Nullable Object value)Attempts to convertvalueto aFloat.static @Nullable IntegerasInt(@Nullable Object value)Attempts to convertvalueto aInteger.static @Nullable LongasLong(@Nullable Object value)Attempts to convertvalueto aLong.static @Nullable StringasString(@Nullable Object value)Attempts to convertvalueto aString.static @Nullable BooleanstrictAsBoolean(@Nullable Object value)Returnsvalueif it is aBoolean.static @Nullable DoublestrictAsDouble(@Nullable Object value)Returnsvalueif it is aDouble.static @Nullable FloatstrictAsFloat(@Nullable Object value)Returnsvalueif it is aFloat.static @Nullable IntegerstrictAsInt(@Nullable Object value)Returnsvalueif it is aInteger.static @Nullable LongstrictAsLong(@Nullable Object value)Returnsvalueif it is aLong.static @Nullable StringstrictAsString(@Nullable Object value)Returnsvalueif it is aString.
-
Method Details
-
asString
Attempts to convertvalueto aString.Returns null if
valueis null, and theObject.toString()representation ofvalueotherwise.- Parameters:
value- The value- Returns:
valueas aString, or null- See Also:
Object.toString()
-
strictAsString
Returnsvalueif it is aString.- Parameters:
value- The value- Returns:
valueas aString, or null
-
asFloat
Attempts to convertvalueto aFloat.Returns null if
valueis null.This method will attempt to cast
valuetoFloat, orparsethevalueif it is aString.- Parameters:
value- The value- Returns:
valueas aFloat, or null
-
strictAsFloat
Returnsvalueif it is aFloat.- Parameters:
value- The value- Returns:
valueas aFloat, or null
-
asDouble
Attempts to convertvalueto aDouble.Returns null if
valueis null.This method will attempt to cast
valuetoDouble, orparsethevalueif it is aString.- Parameters:
value- The value- Returns:
valueas aFloat, or null
-
strictAsDouble
Returnsvalueif it is aDouble.- Parameters:
value- The value- Returns:
valueas aDouble, or null
-
asInt
Attempts to convertvalueto aInteger.Returns null if
valueis null.This method will attempt to cast
valuetoInteger, orparsethevalueif it is aString.- Parameters:
value- The value- Returns:
valueas aFloat, or null
-
strictAsInt
Returnsvalueif it is aInteger.- Parameters:
value- The value- Returns:
valueas aInteger, or null
-
asLong
Attempts to convertvalueto aLong.Returns null if
valueis null.This method will attempt to cast
valuetoLong, orparsethevalueif it is aString.- Parameters:
value- The value- Returns:
valueas aFloat, or null
-
strictAsLong
Returnsvalueif it is aLong.- Parameters:
value- The value- Returns:
valueas aLong, or null
-
asBoolean
Attempts to convertvalueto aBoolean.- Parameters:
value- The value- Returns:
valueas aBoolean, or null
-
strictAsBoolean
Returnsvalueif it is aBoolean.- Parameters:
value- The value- Returns:
valueas aBoolean, or null
-