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:
as
methods attempt to convert the data passed to the appropriate typestrictAs
methods will only return values if the input value is already of an appropriate type
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static @Nullable Boolean
asBoolean(@Nullable Object value)
Attempts to convertvalue
to aBoolean
.static @Nullable Double
asDouble(@Nullable Object value)
Attempts to convertvalue
to aDouble
.static @Nullable Float
asFloat(@Nullable Object value)
Attempts to convertvalue
to aFloat
.static @Nullable Integer
asInt(@Nullable Object value)
Attempts to convertvalue
to aInteger
.static @Nullable Long
asLong(@Nullable Object value)
Attempts to convertvalue
to aLong
.static @Nullable String
asString(@Nullable Object value)
Attempts to convertvalue
to aString
.static @Nullable Boolean
strictAsBoolean(@Nullable Object value)
Returnsvalue
if it is aBoolean
.static @Nullable Double
strictAsDouble(@Nullable Object value)
Returnsvalue
if it is aDouble
.static @Nullable Float
strictAsFloat(@Nullable Object value)
Returnsvalue
if it is aFloat
.static @Nullable Integer
strictAsInt(@Nullable Object value)
Returnsvalue
if it is aInteger
.static @Nullable Long
strictAsLong(@Nullable Object value)
Returnsvalue
if it is aLong
.static @Nullable String
strictAsString(@Nullable Object value)
Returnsvalue
if it is aString
.
-
-
-
Method Detail
-
asString
public static @Nullable String asString(@Nullable Object value)
Attempts to convertvalue
to aString
.Returns null if
value
is null, and theObject.toString()
representation ofvalue
otherwise.- Parameters:
value
- The value- Returns:
value
as aString
, or null- See Also:
Object.toString()
-
strictAsString
public static @Nullable String strictAsString(@Nullable Object value)
Returnsvalue
if it is aString
.- Parameters:
value
- The value- Returns:
value
as aString
, or null
-
asFloat
public static @Nullable Float asFloat(@Nullable Object value)
Attempts to convertvalue
to aFloat
.Returns null if
value
is null.This method will attempt to cast
value
toFloat
, orparse
thevalue
if it is aString
.- Parameters:
value
- The value- Returns:
value
as aFloat
, or null
-
strictAsFloat
public static @Nullable Float strictAsFloat(@Nullable Object value)
Returnsvalue
if it is aFloat
.- Parameters:
value
- The value- Returns:
value
as aFloat
, or null
-
asDouble
public static @Nullable Double asDouble(@Nullable Object value)
Attempts to convertvalue
to aDouble
.Returns null if
value
is null.This method will attempt to cast
value
toDouble
, orparse
thevalue
if it is aString
.- Parameters:
value
- The value- Returns:
value
as aFloat
, or null
-
strictAsDouble
public static @Nullable Double strictAsDouble(@Nullable Object value)
Returnsvalue
if it is aDouble
.- Parameters:
value
- The value- Returns:
value
as aDouble
, or null
-
asInt
public static @Nullable Integer asInt(@Nullable Object value)
Attempts to convertvalue
to aInteger
.Returns null if
value
is null.This method will attempt to cast
value
toInteger
, orparse
thevalue
if it is aString
.- Parameters:
value
- The value- Returns:
value
as aFloat
, or null
-
strictAsInt
public static @Nullable Integer strictAsInt(@Nullable Object value)
Returnsvalue
if it is aInteger
.- Parameters:
value
- The value- Returns:
value
as aInteger
, or null
-
asLong
public static @Nullable Long asLong(@Nullable Object value)
Attempts to convertvalue
to aLong
.Returns null if
value
is null.This method will attempt to cast
value
toLong
, orparse
thevalue
if it is aString
.- Parameters:
value
- The value- Returns:
value
as aFloat
, or null
-
strictAsLong
public static @Nullable Long strictAsLong(@Nullable Object value)
Returnsvalue
if it is aLong
.- Parameters:
value
- The value- Returns:
value
as aLong
, or null
-
asBoolean
public static @Nullable Boolean asBoolean(@Nullable Object value)
Attempts to convertvalue
to aBoolean
.- Parameters:
value
- The value- Returns:
value
as aBoolean
, or null
-
-