-
public final class Convert
Provides utility methods to handle type conversions
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public class
Convert.Lazy
Lazy holder for creating a single instance of Gson on demand.
-
Method Summary
Modifier and Type Method Description static String
toString(@Nullable() Object source, @Nullable() String defaultValue)
Converts the given object into a String object. static String
toString(@Nullable() Object source)
Converts the given object into a String object. static boolean
toBoolean(@Nullable() Object source)
Find the boolean value of the source static long
toLong(@Nullable() Object source, long defaultValue)
Converts the given object into a primitive long value. static long
toLong(@Nullable() Object source)
Converts the given object into a primitive long value. static int
toInt(@Nullable() Object source, int defaultValue)
Converts the given object into a primitive integer value. static int
toInt(@Nullable() Object source)
Converts the given object into a primitive integer value. static <T extends Object> Set<T>
toSet(@Nullable() Array<T> source)
Converts the given primitive array of objects into a Set of objects. static <T extends Object> List<T>
toList(@Nullable() Set<T> source)
Converts a set of objects into a list of objects. static <T extends Object> Set<T>
toSet(@Nullable() Collection<T> source)
Converts the given Collection of objects into a Set of objects. static Array<long>
toPrimitiveLongArray(@Nullable() Collection<out Number> collection)
Converts the give collection of Number objects into an array of primitive long values. static Array<Long>
toLongArray(@Nullable() Collection<out Number> source)
Converts the give collection of Number objects into an array of Long objects. static Array<Long>
toLongArray(@Nullable() Array<long> source)
Converts the give array of primitive long values into an array of Long values. static URI
toURI(@Nullable() Object source)
Converts the give object to an URI object. static String
toHexString(@Nullable() Array<byte> source)
Converts the given array of bytes into hexadecimal string. static String
toJsonString(@Nullable() Object source)
Converts the given object into a JSON formatted string. -
-
Method Detail
-
toString
@Nullable() static String toString(@Nullable() Object source, @Nullable() String defaultValue)
Converts the given object into a String object.
- Parameters:
source
- the object to be converted.defaultValue
- the value that should be returned if the object cannot be converted.
-
toString
@NonNull() static String toString(@Nullable() Object source)
Converts the given object into a String object.
- Parameters:
source
- the object to be converted.
-
toBoolean
static boolean toBoolean(@Nullable() Object source)
Find the boolean value of the source
- Parameters:
source
- the object to be compared.
-
toLong
static long toLong(@Nullable() Object source, long defaultValue)
Converts the given object into a primitive long value.
- Parameters:
source
- the object to be converted.defaultValue
- the value that should be returned if the object cannot be converted.
-
toLong
static long toLong(@Nullable() Object source)
Converts the given object into a primitive long value.
- Parameters:
source
- the object to be converted.
-
toInt
static int toInt(@Nullable() Object source, int defaultValue)
Converts the given object into a primitive integer value.
- Parameters:
source
- the object to be converted.defaultValue
- the value that should be returned if the object cannot be converted.
-
toInt
static int toInt(@Nullable() Object source)
Converts the given object into a primitive integer value.
- Parameters:
source
- the object to be converted.
-
toSet
@NonNull() static <T extends Object> Set<T> toSet(@Nullable() Array<T> source)
Converts the given primitive array of objects into a Set of objects.
- Parameters:
source
- the array of objects to be converted.
-
toList
@NonNull() static <T extends Object> List<T> toList(@Nullable() Set<T> source)
Converts a set of objects into a list of objects.
- Parameters:
source
- the set of objects to be converted.
-
toSet
@NonNull() static <T extends Object> Set<T> toSet(@Nullable() Collection<T> source)
Converts the given Collection of objects into a Set of objects.
- Parameters:
source
- the list of objects to be converted.
-
toPrimitiveLongArray
@NonNull() static Array<long> toPrimitiveLongArray(@Nullable() Collection<out Number> collection)
Converts the give collection of Number objects into an array of primitive long values.
- Parameters:
collection
- a collection of Number objects
-
toLongArray
@NonNull() static Array<Long> toLongArray(@Nullable() Collection<out Number> source)
- Parameters:
source
- a collection of Number objects
-
toLongArray
@NonNull() static Array<Long> toLongArray(@Nullable() Array<long> source)
Converts the give array of primitive long values into an array of Long values.
- Parameters:
source
- an array of primitive long values.
-
toURI
@Nullable() static URI toURI(@Nullable() Object source)
Converts the give object to an URI object.
- Parameters:
source
- the object to be converted.
-
toHexString
@NonNull() static String toHexString(@Nullable() Array<byte> source)
Converts the given array of bytes into hexadecimal string.
- Parameters:
source
- an array of bytes.
-
toJsonString
@NonNull() static String toJsonString(@Nullable() Object source)
Converts the given object into a JSON formatted string.
- Parameters:
source
- the object to be converted.
-
-
-
-