Java Code Examples for com.google.android.exoplayer2.ExoPlayerLibraryInfo#ASSERTIONS_ENABLED

The following examples show how to use com.google.android.exoplayer2.ExoPlayerLibraryInfo#ASSERTIONS_ENABLED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Assertions.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Throws {@link IllegalArgumentException} if {@code string} is null or zero length.
 *
 * @param string The string to check.
 * @return The non-null, non-empty string that was validated.
 * @throws IllegalArgumentException If {@code string} is null or 0-length.
 */
@SuppressWarnings({"contracts.postcondition.not.satisfied", "return.type.incompatible"})
@EnsuresNonNull({"#1"})
public static String checkNotEmpty(@Nullable String string) {
  if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && TextUtils.isEmpty(string)) {
    throw new IllegalArgumentException();
  }
  return string;
}
 
Example 2
Source File: Assertions.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Throws {@link NullPointerException} if {@code reference} is null.
 *
 * @param <T> The type of the reference.
 * @param reference The reference.
 * @return The non-null reference that was validated.
 * @throws NullPointerException If {@code reference} is null.
 */
@SuppressWarnings({"contracts.postcondition.not.satisfied", "return.type.incompatible"})
@EnsuresNonNull({"#1"})
public static <T> T checkNotNull(@Nullable T reference) {
  if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && reference == null) {
    throw new NullPointerException();
  }
  return reference;
}
 
Example 3
Source File: Assertions.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Throws {@link NullPointerException} if {@code reference} is null.
 *
 * @param <T> The type of the reference.
 * @param reference The reference.
 * @return The non-null reference that was validated.
 * @throws NullPointerException If {@code reference} is null.
 */
@SuppressWarnings({"contracts.postcondition.not.satisfied", "return.type.incompatible"})
@EnsuresNonNull({"#1"})
public static <T> T checkNotNull(@Nullable T reference) {
  if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && reference == null) {
    throw new NullPointerException();
  }
  return reference;
}
 
Example 4
Source File: Assertions.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Throws {@link IllegalArgumentException} if {@code string} is null or zero length.
 *
 * @param string The string to check.
 * @return The non-null, non-empty string that was validated.
 * @throws IllegalArgumentException If {@code string} is null or 0-length.
 */
@SuppressWarnings({"contracts.postcondition.not.satisfied", "return.type.incompatible"})
@EnsuresNonNull({"#1"})
public static String checkNotEmpty(@Nullable String string) {
  if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && TextUtils.isEmpty(string)) {
    throw new IllegalArgumentException();
  }
  return string;
}
 
Example 5
Source File: Assertions.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Throws {@link IllegalArgumentException} if {@code string} is null or zero length.
 *
 * @param string The string to check.
 * @return The non-null, non-empty string that was validated.
 * @throws IllegalArgumentException If {@code string} is null or 0-length.
 */
@SuppressWarnings({"contracts.postcondition.not.satisfied", "return.type.incompatible"})
@EnsuresNonNull({"#1"})
public static String checkNotEmpty(@Nullable String string) {
  if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && TextUtils.isEmpty(string)) {
    throw new IllegalArgumentException();
  }
  return string;
}
 
Example 6
Source File: Assertions.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Throws {@link NullPointerException} if {@code reference} is null.
 *
 * @param <T> The type of the reference.
 * @param reference The reference.
 * @return The non-null reference that was validated.
 * @throws NullPointerException If {@code reference} is null.
 */
@SuppressWarnings({"contracts.postcondition.not.satisfied", "return.type.incompatible"})
@EnsuresNonNull({"#1"})
public static <T> T checkNotNull(@Nullable T reference) {
  if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && reference == null) {
    throw new NullPointerException();
  }
  return reference;
}
 
Example 7
Source File: Assertions.java    From K-Sonic with MIT License 3 votes vote down vote up
/**
 * Throws {@link NullPointerException} if {@code reference} is null.
 *
 * @param <T> The type of the reference.
 * @param reference The reference.
 * @param errorMessage The exception message to use if the check fails. The message is converted
 *     to a string using {@link String#valueOf(Object)}.
 * @return The non-null reference that was validated.
 * @throws NullPointerException If {@code reference} is null.
 */
public static <T> T checkNotNull(T reference, Object errorMessage) {
  if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && reference == null) {
    throw new NullPointerException(String.valueOf(errorMessage));
  }
  return reference;
}
 
Example 8
Source File: Assertions.java    From TelePlus-Android with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Throws {@link IllegalArgumentException} if {@code string} is null or zero length.
 *
 * @param string The string to check.
 * @param errorMessage The exception message to use if the check fails. The message is converted
 *     to a string using {@link String#valueOf(Object)}.
 * @return The non-null, non-empty string that was validated.
 * @throws IllegalArgumentException If {@code string} is null or 0-length.
 */
@SuppressWarnings({"contracts.postcondition.not.satisfied", "return.type.incompatible"})
@EnsuresNonNull({"#1"})
public static String checkNotEmpty(@Nullable String string, Object errorMessage) {
  if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && TextUtils.isEmpty(string)) {
    throw new IllegalArgumentException(String.valueOf(errorMessage));
  }
  return string;
}
 
Example 9
Source File: Assertions.java    From TelePlus-Android with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Throws {@link IllegalArgumentException} if {@code string} is null or zero length.
 *
 * @param string The string to check.
 * @param errorMessage The exception message to use if the check fails. The message is converted
 *     to a string using {@link String#valueOf(Object)}.
 * @return The non-null, non-empty string that was validated.
 * @throws IllegalArgumentException If {@code string} is null or 0-length.
 */
@SuppressWarnings({"contracts.postcondition.not.satisfied", "return.type.incompatible"})
@EnsuresNonNull({"#1"})
public static String checkNotEmpty(@Nullable String string, Object errorMessage) {
  if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && TextUtils.isEmpty(string)) {
    throw new IllegalArgumentException(String.valueOf(errorMessage));
  }
  return string;
}
 
Example 10
Source File: Assertions.java    From MediaSDK with Apache License 2.0 3 votes vote down vote up
/**
 * Throws {@link NullPointerException} if {@code reference} is null.
 *
 * @param <T> The type of the reference.
 * @param reference The reference.
 * @param errorMessage The exception message to use if the check fails. The message is converted
 *     to a string using {@link String#valueOf(Object)}.
 * @return The non-null reference that was validated.
 * @throws NullPointerException If {@code reference} is null.
 */
@SuppressWarnings({"contracts.postcondition.not.satisfied", "return.type.incompatible"})
@EnsuresNonNull({"#1"})
public static <T> T checkNotNull(@Nullable T reference, Object errorMessage) {
  if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && reference == null) {
    throw new NullPointerException(String.valueOf(errorMessage));
  }
  return reference;
}
 
Example 11
Source File: Assertions.java    From TelePlus-Android with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Throws {@link NullPointerException} if {@code reference} is null.
 *
 * @param <T> The type of the reference.
 * @param reference The reference.
 * @param errorMessage The exception message to use if the check fails. The message is converted
 *     to a string using {@link String#valueOf(Object)}.
 * @return The non-null reference that was validated.
 * @throws NullPointerException If {@code reference} is null.
 */
@SuppressWarnings({"contracts.postcondition.not.satisfied", "return.type.incompatible"})
@EnsuresNonNull({"#1"})
public static <T> T checkNotNull(@Nullable T reference, Object errorMessage) {
  if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && reference == null) {
    throw new NullPointerException(String.valueOf(errorMessage));
  }
  return reference;
}
 
Example 12
Source File: Assertions.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Throws {@link IllegalStateException} if the calling thread is not the application's main
 * thread.
 *
 * @throws IllegalStateException If the calling thread is not the application's main thread.
 */
public static void checkMainThread() {
  if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && Looper.myLooper() != Looper.getMainLooper()) {
    throw new IllegalStateException("Not in applications main thread");
  }
}
 
Example 13
Source File: Assertions.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Throws {@link IllegalStateException} if {@code expression} evaluates to false.
 *
 * @param expression The expression to evaluate.
 * @param errorMessage The exception message if an exception is thrown. The message is converted
 *     to a {@link String} using {@link String#valueOf(Object)}.
 * @throws IllegalStateException If {@code expression} is false.
 */
public static void checkState(boolean expression, Object errorMessage) {
  if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && !expression) {
    throw new IllegalStateException(String.valueOf(errorMessage));
  }
}
 
Example 14
Source File: Assertions.java    From Telegram with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Throws {@link IllegalStateException} if {@code expression} evaluates to false.
 *
 * @param expression The expression to evaluate.
 * @throws IllegalStateException If {@code expression} is false.
 */
public static void checkState(boolean expression) {
  if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && !expression) {
    throw new IllegalStateException();
  }
}
 
Example 15
Source File: Assertions.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Throws {@link IllegalStateException} if {@code expression} evaluates to false.
 *
 * @param expression The expression to evaluate.
 * @param errorMessage The exception message if an exception is thrown. The message is converted
 *     to a {@link String} using {@link String#valueOf(Object)}.
 * @throws IllegalStateException If {@code expression} is false.
 */
public static void checkState(boolean expression, Object errorMessage) {
  if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && !expression) {
    throw new IllegalStateException(String.valueOf(errorMessage));
  }
}
 
Example 16
Source File: Assertions.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Throws {@link IllegalArgumentException} if {@code expression} evaluates to false.
 *
 * @param expression The expression to evaluate.
 * @throws IllegalArgumentException If {@code expression} is false.
 */
public static void checkArgument(boolean expression) {
  if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && !expression) {
    throw new IllegalArgumentException();
  }
}
 
Example 17
Source File: Assertions.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Throws {@link IllegalArgumentException} if {@code expression} evaluates to false.
 *
 * @param expression The expression to evaluate.
 * @throws IllegalArgumentException If {@code expression} is false.
 */
public static void checkArgument(boolean expression) {
  if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && !expression) {
    throw new IllegalArgumentException();
  }
}
 
Example 18
Source File: Assertions.java    From Telegram-FOSS with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Throws {@link IllegalArgumentException} if {@code expression} evaluates to false.
 *
 * @param expression The expression to evaluate.
 * @param errorMessage The exception message if an exception is thrown. The message is converted
 *     to a {@link String} using {@link String#valueOf(Object)}.
 * @throws IllegalArgumentException If {@code expression} is false.
 */
public static void checkArgument(boolean expression, Object errorMessage) {
  if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && !expression) {
    throw new IllegalArgumentException(String.valueOf(errorMessage));
  }
}
 
Example 19
Source File: Assertions.java    From K-Sonic with MIT License 2 votes vote down vote up
/**
 * Throws {@link IllegalStateException} if {@code expression} evaluates to false.
 *
 * @param expression The expression to evaluate.
 * @throws IllegalStateException If {@code expression} is false.
 */
public static void checkState(boolean expression) {
  if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && !expression) {
    throw new IllegalStateException();
  }
}
 
Example 20
Source File: Assertions.java    From K-Sonic with MIT License 2 votes vote down vote up
/**
 * Throws {@link IllegalStateException} if the calling thread is not the application's main
 * thread.
 *
 * @throws IllegalStateException If the calling thread is not the application's main thread.
 */
public static void checkMainThread() {
  if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && Looper.myLooper() != Looper.getMainLooper()) {
    throw new IllegalStateException("Not in applications main thread");
  }
}