Class Convert

java.lang.Object
com.brightcove.player.util.Convert

public final class Convert extends Object
Provides utility methods to handle type conversions
  • Method Details

    • toString

      @Nullable public 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.
      Returns:
      the converted string.
    • toString

      @NonNull public static String toString(@Nullable Object source)
      Converts the given object into a String object.
      Parameters:
      source - the object to be converted.
      Returns:
      the converted string.
    • toBoolean

      public static boolean toBoolean(@Nullable 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 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 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 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 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> Set<T> toSet(@Nullable T[] source)
      Converts the given primitive array of objects into a Set 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

      @NonNull public static <T> List<T> toList(@Nullable 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> Set<T> toSet(@Nullable Collection<T> source)
      Converts the given Collection of objects into a Set 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 of Number objects into an array of primitive long values.
      Parameters:
      collection - a collection of Number objects
      Returns:
      an array of primitive long values.
    • toLongArray

      @NonNull public static Long[] toLongArray(@Nullable Collection<? extends Number> source)
      Converts the give collection of Number objects into an array of Long objects.
      Parameters:
      source - a collection of Number objects
      Returns:
      an array of Long objects.
    • toLongArray

      @NonNull public static Long[] toLongArray(@Nullable long[] source)
      Converts the give array of primitive long values into an array of Long values.
      Parameters:
      source - an array of primitive long values.
      Returns:
      an array of Long objects.
    • toURI

      @Nullable public static URI toURI(@Nullable Object source)
      Converts the give object to an URI object.
      Parameters:
      source - the object to be converted.
      Returns:
      null if the source is null, otherwise the URI.
    • toHexString

      @NonNull public static 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 String toJsonString(@Nullable Object source)
      Converts the given object into a JSON formatted string.
      Parameters:
      source - the object to be converted.
      Returns:
      the converted value.