工具類--字串工具類
阿新 • • 發佈:2021-10-27
package com.jyc.common.utils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.jyc.common.core.text.StrFormatter;
/**
* 字串工具類
*
* @author jianyongchao
*/
public class StringUtils extends org.apache.commons.lang3.StringUtils
{
/** 空字串 */
private static final String NULLSTR = "";
/** 下劃線 */
private static final char SEPARATOR = '_';
/**
* 獲取引數不為空值
*
* @param value defaultValue 要判斷的value
* @return value 返回值
*/
public static <T> T nvl(T value, T defaultValue)
{
return value != null ? value : defaultValue;
}
/**
* * 判斷一個Collection是否為空, 包含List,Set,Queue
*
* @param coll 要判斷的Collection
* @return true:為空 false:非空
*/
public static boolean isEmpty(Collection<?> coll)
{
return isNull(coll) || coll.isEmpty();
}
/**
* * 判斷一個Collection是否非空,包含List,Set,Queue
*
* @param coll 要判斷的Collection
* @return true:非空 false:空
*/
public static boolean isNotEmpty(Collection<?> coll)
{
return !isEmpty(coll);
}
/**
* * 判斷一個物件陣列是否為空
*
* @param objects 要判斷的物件陣列
** @return true:為空 false:非空
*/
public static boolean isEmpty(Object[] objects)
{
return isNull(objects) || (objects.length == 0);
}
/**
* * 判斷一個物件陣列是否非空
*
* @param objects 要判斷的物件陣列
* @return true:非空 false:空
*/
public static boolean isNotEmpty(Object[] objects)
{
return !isEmpty(objects);