package junkutil.common;

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

/**
 * nullを処理する
 * @author Hiroyuki Shiota
 */
public class NullUtil {
	/**
	 * コンストラクタ
	 */
	private NullUtil() {}

	/**
	 * nvl
	 * @param arg
	 * @return
	 */
	public static String nvl(String arg) {
		if (arg == null) return "";
		return arg;
	}

	/**
	 * nvl
	 * @param arg
	 * @param fallback
	 * @return
	 */
	public static String nvl(String arg, String fallback) {
		if (arg == null) return fallback;
		return arg;
	}

	/**
	 * nvlNull
	 * @param arg
	 * @return
	 */
	public static String nvlNull(String arg) {
		if (arg == null) return "null";
		return arg;
	}

	/**
	 * nvlObject
	 * @param arg
	 * @return
	 */
	public static Object nvlObject(Object arg) {
		if (arg == null) return "";
		return arg.toString();
	}

	/**
	 * nvlNull
	 * @param arg
	 * @return
	 */
	public static Object nvlNull(Object arg) {
		if (arg == null) return "null";
		return arg;
	}

	/**
	 * nvlObject
	 * @param arg
	 * @param fallback
	 * @return
	 */
	public static String nvlObject(Object arg, String fallback) {
		if (arg == null) return fallback;
		return arg.toString();
	}

	/**
	 * nvlObject
	 * @param arg
	 * @param fallback
	 * @return
	 */
	public static Object nvlObject(Object arg, Object fallback) {
		if (arg == null) return fallback;
		return arg;
	}

	/**
	 * nvlList
	 * @param arg
	 * @param fallback
	 * @return
	 */
	public static List nvlList(List arg, List fallback) {
		if (arg == null) return fallback;
		return arg;
	}

	/**
	 * nvlMap
	 * @param arg
	 * @param fallback
	 * @return
	 */
	public static Map nvlMap(Map arg, Map fallback) {
		if (arg == null) return fallback;
		return arg;
	}
}
