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
Nested ClassesModifier and TypeClassDescriptionstatic classLazy holder for creating a single instance ofGsonon demand. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanFind the boolean value of the sourcestatic StringtoHexString(byte[] source) Converts the given array of bytes into hexadecimal string.static intConverts the given object into a primitive integer value.static intConverts the given object into a primitive integer value.static StringtoJsonString(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 longConverts the given object into a primitive long value.static longConverts the given object into a primitive long value.static Long[]toLongArray(long[] source) Converts the give array of primitive long values into an array ofLongvalues.static Long[]toLongArray(Collection<? extends Number> source) static long[]toPrimitiveLongArray(Collection<? extends Number> collection) Converts the give collection ofNumberobjects into an array of primitive long values.static <T> Set<T>toSet(Collection<T> source) Converts the givenCollectionof objects into aSetof objects.static <T> Set<T>toSet(T[] source) Converts the given primitive array of objects into aSetof objects.static StringConverts the given object into aStringobject.static StringConverts the given object into aStringobject.static URIConverts the give object to anURIobject.
-
Method Details
-
toString
Converts the given object into aStringobject.- 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 aStringobject.- 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 aSetof objects.- Type Parameters:
T- the type of the object.- Parameters:
source- the array of objects to be converted.- Returns:
- reference to a
Setcontaining 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 givenCollectionof objects into aSetof objects.- Type Parameters:
T- the type of the object.- Parameters:
source- the list of objects to be converted.- Returns:
- reference to a
Setcontaining the objects.
-
toPrimitiveLongArray
@NonNull public static long[] toPrimitiveLongArray(@Nullable Collection<? extends Number> collection) Converts the give collection ofNumberobjects into an array of primitive long values.- Parameters:
collection- a collection ofNumberobjects- Returns:
- an array of primitive long values.
-
toLongArray
-
toLongArray
Converts the give array of primitive long values into an array ofLongvalues.- Parameters:
source- an array of primitive long values.- Returns:
- an array of
Longobjects.
-
toURI
Converts the give object to anURIobject.- 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.
-