Package com.flowlogix.util
Class TypeConverter
java.lang.Object
com.flowlogix.util.TypeConverter
Converts from any String to any type dynamically,
using static
valueOf(String input) method of the target type
Accepts database special values, such as inf, -inf, and nan
Example:
int one = TypeConverter.valueOf("1", int.class);
- Author:
- lprimak
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class -
Method Summary
Modifier and TypeMethodDescriptionstatic <TT> TypeConverter.CheckedValue<TT>checkAndConvert(@NonNull String value, @NonNull Class<TT> type) static <TT> booleanCheck if conversion will succeedstatic <TT> TTstatic ObjectConvert string to object given a type name
-
Method Details
-
valueOf
- Type Parameters:
TT- type of result objects- Parameters:
strValue- inputtype- type of result- Returns:
- value
-
valueOf
public static Object valueOf(@NonNull @NonNull String strValue, @NonNull @NonNull String type) throws IllegalArgumentException Convert string to object given a type name- Parameters:
strValue-type-- Returns:
- object after conversion
- Throws:
IllegalArgumentException
-
checkType
public static <TT> boolean checkType(@NonNull @NonNull String value, @NonNull @NonNull Class<TT> type) Check if conversion will succeed- Type Parameters:
TT- type of class- Parameters:
value-type-- Returns:
- true if conversion is good
-
checkAndConvert
public static <TT> TypeConverter.CheckedValue<TT> checkAndConvert(@NonNull @NonNull String value, @NonNull @NonNull Class<TT> type) - Type Parameters:
TT- type of class- Parameters:
value-type-- Returns:
- checked type
-