Package com.brightcove.player.util
Class Convert
java.lang.Object
com.brightcove.player.util.Convert
Provides utility methods to handle type conversions
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Lazy holder for creating a single instance ofGson
on demand. -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Find the boolean value of the sourcestatic String
toHexString
(byte[] source) Converts the given array of bytes into hexadecimal string.static int
Converts the given object into a primitive integer value.static int
Converts the given object into a primitive integer value.static String
toJsonString
(Object source) Converts the given object into a JSON formatted string.static <T> List<T>
Converts a set of objects into a list of objects.static long
Converts the given object into a primitive long value.static long
Converts the given object into a primitive long value.static Long[]
toLongArray
(long[] source) Converts the give array of primitive long values into an array ofLong
values.static Long[]
toLongArray
(Collection<? extends Number> source) static long[]
toPrimitiveLongArray
(Collection<? extends Number> collection) Converts the give collection ofNumber
objects into an array of primitive long values.static <T> Set<T>
toSet
(Collection<T> source) Converts the givenCollection
of objects into aSet
of objects.static <T> Set<T>
toSet
(T[] source) Converts the given primitive array of objects into aSet
of objects.static String
Converts the given object into aString
object.static String
Converts the given object into aString
object.static URI
Converts the give object to anURI
object.
-
Method Details
-
toString
Converts the given object into aString
object.- Parameters:
source
- the object to be converted.defaultValue
- the value that should be returned if the object cannot be converted.- Returns:
- the converted string.
-
toString
Converts the given object into aString
object.- Parameters:
source
- the object to be converted.- Returns:
- the converted string.
-
toBoolean
Find the boolean value of the source- Parameters:
source
- the object to be compared.- Returns:
- true or false
-
toLong
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.- Returns:
- the converted value.
-
toLong
Converts the given object into a primitive long value.- Parameters:
source
- the object to be converted.- Returns:
- the converted value.
-
toInt
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.- Returns:
- the converted value.
-
toInt
Converts the given object into a primitive integer value.- Parameters:
source
- the object to be converted.- Returns:
- the converted value.
-
toSet
Converts the given primitive array of objects into aSet
of objects.- Type Parameters:
T
- the type of the object.- Parameters:
source
- the array of objects to be converted.- Returns:
- reference to a
Set
containing the objects.
-
toList
Converts a set of objects into a list of objects.- Type Parameters:
T
-- Parameters:
source
- the set of objects to be converted.- Returns:
- the list of objects.
-
toSet
Converts the givenCollection
of objects into aSet
of objects.- Type Parameters:
T
- the type of the object.- Parameters:
source
- the list of objects to be converted.- Returns:
- reference to a
Set
containing the objects.
-
toPrimitiveLongArray
@NonNull public static long[] toPrimitiveLongArray(@Nullable Collection<? extends Number> collection) Converts the give collection ofNumber
objects into an array of primitive long values.- Parameters:
collection
- a collection ofNumber
objects- Returns:
- an array of primitive long values.
-
toLongArray
-
toLongArray
Converts the give array of primitive long values into an array ofLong
values.- Parameters:
source
- an array of primitive long values.- Returns:
- an array of
Long
objects.
-
toURI
Converts the give object to anURI
object.- Parameters:
source
- the object to be converted.- Returns:
- null if the source is null, otherwise the URI.
-
toHexString
Converts the given array of bytes into hexadecimal string.- Parameters:
source
- an array of bytes.- Returns:
- the converted hexadecimal string.
-
toJsonString
Converts the given object into a JSON formatted string.- Parameters:
source
- the object to be converted.- Returns:
- the converted value.
-