非空验证工具类String
来源:互联网 发布:世界首家网络银行是 编辑:程序博客网 时间:2024/06/04 08:49
package com.yanshu.util;
import java.util.Map;
/**
* 非空验证工具类
*/
public class StringUtils {
/**
* @see: 验证string类型的是否为空
*/
public static boolean isNullorEmpty(String str) {
//为了执行忽略大小写的比较,可以调用equalsIgnoreCase( )方法。当比较两个字符串时,它会认为A-Z和a-z是一样的。
if ((str == null) || ("".equals(str)) || ("null".equalsIgnoreCase(str)) || ("undefined".equalsIgnoreCase(str))) {
return true;
}
return false;
}
public static boolean isNotEmpty(String str)
{
if(str!=null)
{
return true;
}
return false;
}
/**
* @see: 验证实体是否为空
*/
public static <T> boolean isNullorEmpty(T entity) {
if (entity == null) {
return true;
} else {
return false;
}
}
/**
* @see: 验证StringBuffer类型的是否为空
*/
public static boolean isNullorEmpty(StringBuffer str) {
if (str == null ||"".equals(str.toString()) || str.length() == 0) {
return true;
} else {
return false;
}
}
/**
* @see: 验证Map类型的是否为空
*/
public static boolean isNullorEmpty(Map map) {
if ((map == null) || (map.size() == 0)) {
return true;
}
return false;
}
/**
* @see: 验证Object数组类型的是否为空
*/
public static boolean isNullorEmpty(Object[] obj) {
if ((obj == null) || (obj.length == 0)) {
return true;
}
return false;
}
/**
* @see: 验证Long类型的是否为空
*/
public static boolean isNullorEmpty(Long longTime) {
if ((longTime == null) || (longTime.longValue() <= 0L)) {
return true;
}
return false;
}
/**
* @see: 验证String数组类型的是否为空
*/
public static boolean isNullorEmpty(String[] str) {
if ((str == null) || (str.length == 0)) {
return true;
}
return false;
}
}
import java.util.Map;
/**
* 非空验证工具类
*/
public class StringUtils {
/**
* @see: 验证string类型的是否为空
*/
public static boolean isNullorEmpty(String str) {
//为了执行忽略大小写的比较,可以调用equalsIgnoreCase( )方法。当比较两个字符串时,它会认为A-Z和a-z是一样的。
if ((str == null) || ("".equals(str)) || ("null".equalsIgnoreCase(str)) || ("undefined".equalsIgnoreCase(str))) {
return true;
}
return false;
}
public static boolean isNotEmpty(String str)
{
if(str!=null)
{
return true;
}
return false;
}
/**
* @see: 验证实体是否为空
*/
public static <T> boolean isNullorEmpty(T entity) {
if (entity == null) {
return true;
} else {
return false;
}
}
/**
* @see: 验证StringBuffer类型的是否为空
*/
public static boolean isNullorEmpty(StringBuffer str) {
if (str == null ||"".equals(str.toString()) || str.length() == 0) {
return true;
} else {
return false;
}
}
/**
* @see: 验证Map类型的是否为空
*/
public static boolean isNullorEmpty(Map map) {
if ((map == null) || (map.size() == 0)) {
return true;
}
return false;
}
/**
* @see: 验证Object数组类型的是否为空
*/
public static boolean isNullorEmpty(Object[] obj) {
if ((obj == null) || (obj.length == 0)) {
return true;
}
return false;
}
/**
* @see: 验证Long类型的是否为空
*/
public static boolean isNullorEmpty(Long longTime) {
if ((longTime == null) || (longTime.longValue() <= 0L)) {
return true;
}
return false;
}
/**
* @see: 验证String数组类型的是否为空
*/
public static boolean isNullorEmpty(String[] str) {
if ((str == null) || (str.length == 0)) {
return true;
}
return false;
}
}
阅读全文
0 0
- 非空验证工具类String
- 常用非空工具类
- 非空判定工具类
- 10.2 非空验证
- JS 非空验证
- js 非空验证
- js非空验证
- jquery 验证非空
- js非空验证
- jQuery非空验证
- 表格验证非空
- String非空判断
- JavaScript_form表单非空验证;
- js提交验证非空
- HTML js非空验证
- 验证非空和数字
- 非空验证 注册用户信息
- java String非空判断
- 简单版的JDBC存储过程--输入通用方法
- NKOJ 2784 (APIO 2013) 道路费用(最小生成树+缩点)
- Ubuntu16.04 安装 Figaro
- 第十节:定位以及切换frame(iframe)
- Python中变量的命名和使用
- 非空验证工具类String
- leeetcode283. Move Zeroes
- HTML5中的video&audio
- 欢迎使用CSDN-markdown编辑器
- leetcode27. Remove Element
- Dx 79 error; aborting
- Nginx Rtmp Module Study 之基本数据结构ngx_module_t
- 【07】Bootstrap — Form表单
- 如何使用JavaScript