Package com.brightcove.player.util
Class Convert
- java.lang.Object
-
- com.brightcove.player.util.Convert
-
public final class Convert extends java.lang.ObjectProvides utility methods to handle type conversions
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConvert.LazyLazy holder for creating a single instance ofGsonon demand.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleantoBoolean(java.lang.Object source)Find the boolean value of the sourcestatic java.lang.StringtoHexString(byte[] source)Converts the given array of bytes into hexadecimal string.static inttoInt(java.lang.Object source)Converts the given object into a primitive integer value.static inttoInt(java.lang.Object source, int defaultValue)Converts the given object into a primitive integer value.static java.lang.StringtoJsonString(java.lang.Object source)Converts the given object into a JSON formatted string.static <T> java.util.List<T>toList(java.util.Set<T> source)Converts a set of objects into a list of objects.static longtoLong(java.lang.Object source)Converts the given object into a primitive long value.static longtoLong(java.lang.Object source, long defaultValue)Converts the given object into a primitive long value.static java.lang.Long[]toLongArray(long[] source)Converts the give array of primitive long values into an array ofLongvalues.static java.lang.Long[]toLongArray(java.util.Collection<? extends java.lang.Number> source)Converts the give collection ofNumberobjects into an array ofLongobjects.static long[]toPrimitiveLongArray(java.util.Collection<? extends java.lang.Number> collection)Converts the give collection ofNumberobjects into an array of primitive long values.static <T> java.util.Set<T>toSet(java.util.Collection<T> source)Converts the givenCollectionof objects into aSetof objects.static <T> java.util.Set<T>toSet(T[] source)Converts the given primitive array of objects into aSetof objects.static java.lang.StringtoString(java.lang.Object source)Converts the given object into aStringobject.static java.lang.StringtoString(java.lang.Object source, java.lang.String defaultValue)Converts the given object into aStringobject.static java.net.URItoURI(java.lang.Object source)Converts the give object to anURIobject.
-
-
-
Method Detail
-
toString
@Nullable public static java.lang.String toString(@Nullable java.lang.Object source, @Nullable java.lang.String defaultValue)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
@NonNull public static java.lang.String toString(@Nullable java.lang.Object source)Converts the given object into aStringobject.- Parameters:
source- the object to be converted.- Returns:
- the converted string.
-
toBoolean
public static boolean toBoolean(@Nullable java.lang.Object source)Find the boolean value of the source- Parameters:
source- the object to be compared.- Returns:
- true or false
-
toLong
public static long toLong(@Nullable java.lang.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.- Returns:
- the converted value.
-
toLong
public static long toLong(@Nullable java.lang.Object source)Converts the given object into a primitive long value.- Parameters:
source- the object to be converted.- Returns:
- the converted value.
-
toInt
public static int toInt(@Nullable java.lang.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.- Returns:
- the converted value.
-
toInt
public static int toInt(@Nullable java.lang.Object source)Converts the given object into a primitive integer value.- Parameters:
source- the object to be converted.- Returns:
- the converted value.
-
toSet
@NonNull public static <T> java.util.Set<T> toSet(@Nullable T[] source)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
@NonNull public static <T> java.util.List<T> toList(@Nullable java.util.Set<T> source)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
@NonNull public static <T> java.util.Set<T> toSet(@Nullable java.util.Collection<T> source)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 java.util.Collection<? extends java.lang.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
@NonNull public static java.lang.Long[] toLongArray(@Nullable java.util.Collection<? extends java.lang.Number> source)Converts the give collection ofNumberobjects into an array ofLongobjects.- Parameters:
source- a collection ofNumberobjects- Returns:
- an array of
Longobjects.
-
toLongArray
@NonNull public static java.lang.Long[] toLongArray(@Nullable long[] source)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
@Nullable public static java.net.URI toURI(@Nullable java.lang.Object source)Converts the give object to anURIobject.- Parameters:
source- the object to be converted.- Returns:
- null if the source is null, otherwise the URI.
-
toHexString
@NonNull public static java.lang.String toHexString(@Nullable byte[] source)Converts the given array of bytes into hexadecimal string.- Parameters:
source- an array of bytes.- Returns:
- the converted hexadecimal string.
-
toJsonString
@NonNull public static java.lang.String toJsonString(@Nullable java.lang.Object source)Converts the given object into a JSON formatted string.- Parameters:
source- the object to be converted.- Returns:
- the converted value.
-
-