java工具类
来源:互联网 发布:多益网络java面试题 编辑:程序博客网 时间:2024/05/03 07:25
Also its good to know that, if you are overridding .equals () method, make sure you are overridding .hashcode () method, otherwise you will end up with violating equivalence relation b/w equals and hashcode// 最好借助于Apache 工具类防止 findBugs 检查出问题[看源码实现方式]import org.apache.commons.collections.CollectionUtils;import org.apache.commons.lang.StringUtils;import org.apache.commons.lang.time.DateUtils;public static boolean isBlank(String str){int strLen;if(str == null || (strLen = str.length()) == 0)return true;for(int i = 0; i < strLen; i++)if(!Character.isWhitespace(str.charAt(i)))return false;return true;}public static boolean equals(String str1, String str2){return str1 != null ? str1.equals(str2) : str2 == null;}public static boolean equalsIgnoreCase(String str1, String str2){return str1 != null ? str1.equalsIgnoreCase(str2) : str2 == null;}
package com.qingyaun.kehua.customization.util;import java.util.Collection;import java.util.Map;/** * Get utils from here listed: * @see http://commons.apache.org/downloads/index.html<Lang,Logging,Math,BeanUtils,etc.....> * @see http://www.java2s.com/Code/Jar/g/Downloadgson222jar.htm * @See org.apache.commons.collections.CollectionUtils; * @See org.apache.commons.lang.StringUtils; * @See org.apache.commons.lang.time.DateUtils; * @author: xiongqingyuan * @date 2014-6-20 * if (NullCheckUtils.isNotNull(ds) && StringUtils.equals(ParamHandleUtil.FLAG, ds.getFlag())) * { * ds2List(list, ds); * } */@SuppressWarnings("unchecked")public class NullCheckUtils{ public static boolean isNullOrEmpty(Collection collection) { return (null == collection || 0 == collection.size())? true: false; } public static boolean isNotNullAndEmpty(Collection collection) { return !isNullOrEmpty(collection); } public static boolean isNullOrEmpty(Map map) { return (null == map || 0 == map.size())? true: false; } public static boolean isNotNullAndEmpty(Map map) { return !isNullOrEmpty(map); } public static boolean isNullOrEmpty(Object[] objects) { return (null == objects || 0 == objects.length)? true: false; } public static boolean isNotNullAndEmpty(Object[] objects) { return !isNullOrEmpty(objects); } public static boolean isNull(Object object) { return (null == object)? true: false; } public static boolean isNotNull(Object Object) { return !isNull(Object); } public static boolean isNullOrEmpty(String subject) { return (null == subject || "".equals(subject))? true: false; } public static boolean isNotNullAndEmpty(String subject) { return !isNullOrEmpty(subject); } }
0 0
- java文件工具类
- java日期工具类
- java 绝对路径工具类
- java工具类
- Java 数据处理工具类
- java日期工具类
- java工具类Assert
- 一些Java工具类
- anroid&java工具类
- java StringUtil 工具类
- java身份证号工具类
- java 日期工具类
- Java开发工具类
- java 加密工具类
- java集合工具类
- java时间工具类
- java 时间工具类
- Java加密工具类
- 【leetcode】 ZigZag Conversion
- 理解Session与Cookie
- poj1005
- iOS 电话 短信 邮件等等
- 逆序对
- java工具类
- Apache之AllowOverride参数详解
- Unity网格合并
- UVA - 146 - ID Codes (枚举排列)
- 有关数据库设计中的几种范式的总结
- 欧拉回路&特殊图下的哈密顿图回路题集
- HDU3926Hand in Hand(搜索 或 并查集)
- 创建Mat 对象
- PE 22 Names scores