package com.engine.htsc.payment.util;


import java.util.List;
import java.util.Map;

public final class AssertUtil {

	/**
	 * 判断对象为空
	 * @param obj 对象名
	 */
	@SuppressWarnings("rawtypes")
	public static boolean isEmpty(Object obj) {
		if (obj == null) {
			return true;
		}
		if ((obj instanceof String)) {
			return ((String) obj).trim().equals("");
		}
		if ((obj instanceof List)) {
			return ((List) obj).isEmpty();
		}
		if ((obj instanceof Map)) {
			return ((Map) obj).isEmpty();
		}
		return false;
	}

	/**
	 * 判断对象为空
	 * @param obj 对象名
	 */
	public static boolean isNotEmpty(Object obj) {
		return !isEmpty(obj);
	}

	/**
	 * 判断对象为空
	 * @param obj 对象名
	 */
	public static void isEmpty(Object obj, String msg) {
		isTrue(isEmpty(obj), msg);
	}

	public static void isTrue(Boolean flag, String msg) {
		if (flag) {
			throw new IllegalArgumentException(msg);
		}
	}

}
