All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bumptech.glide.util.Preconditions Maven / Gradle / Ivy

Go to download

A fast and efficient image loading library for Android focused on smooth scrolling.

There is a newer version: 5.0.0-rc01
Show newest version
package com.bumptech.glide.util;

import android.text.TextUtils;
import java.util.Collection;

/**
 * Contains common assertions.
 */
public final class Preconditions {

  private Preconditions() {
    // Utility class.
  }

  public static void checkArgument(boolean expression, String message) {
    if (!expression) {
      throw new IllegalArgumentException(message);
    }
  }

  public static  T checkNotNull(T arg) {
    return checkNotNull(arg, "Argument must not be null");
  }

  public static  T checkNotNull(T arg, String message) {
    if (arg == null) {
      throw new NullPointerException(message);
    }
    return arg;
  }

  public static String checkNotEmpty(String string) {
    if (TextUtils.isEmpty(string)) {
      throw new IllegalArgumentException("Must not be null or empty");
    }
    return string;
  }

  public static , Y> T checkNotEmpty(T collection) {
    if (collection.isEmpty()) {
      throw new IllegalArgumentException("Must not be empty.");
    }
    return collection;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy