package com.ffii.core.utils;

import java.math.BigDecimal;
import java.util.Collection;
import java.util.Map;
import java.util.function.Supplier;

import org.apache.commons.lang3.StringUtils;

public abstract class AssertUtils {
  public static void isTrue(boolean v, Supplier<RuntimeException> errSupplier) {
    if (!v) throw errSupplier.get();
  }

  public static void isFalse(boolean v, Supplier<RuntimeException> errSupplier) {
    if (v) throw errSupplier.get();
  }

  public static void isNotNull(Object v, Supplier<RuntimeException> errSupplier) {
    if (v == null) throw errSupplier.get();
  }

  public static void isNull(Object v, Supplier<RuntimeException> errSupplier) {
    if (v != null) throw errSupplier.get();
  }

  public static void isNotEmpty(Collection<?> v, Supplier<RuntimeException> errSupplier) {
    if (v.isEmpty()) throw errSupplier.get();
  }

  public static void isEmpty(Collection<?> v, Supplier<RuntimeException> errSupplier) {
    if (!v.isEmpty()) throw errSupplier.get();
  }

  public static void isNotEmpty(Map<?, ?> v, Supplier<RuntimeException> errSupplier) {
    if (v.isEmpty()) throw errSupplier.get();
  }

  public static void isEmpty(Map<?, ?> v, Supplier<RuntimeException> errSupplier) {
    if (!v.isEmpty()) throw errSupplier.get();
  }

  public static void isNotBlank(String s, Supplier<RuntimeException> errSupplier) {
    if (StringUtils.isBlank(s)) throw errSupplier.get();
  }

  public static void isBlank(String s, Supplier<RuntimeException> errSupplier) {
    if (StringUtils.isNotBlank(s)) throw errSupplier.get();
  }

  public static void isZero(BigDecimal bd, Supplier<RuntimeException> errSupplier) {
    if (BigDecimal.ZERO.equals(bd)) throw errSupplier.get();
  }

  public static void isZero(Number i, Supplier<RuntimeException> errSupplier) {
    if (i.equals(0)) throw errSupplier.get();
  }

}
