字符串和对象判空工具类
来源:互联网 发布:淘宝闲鱼怎么举报买家 编辑:程序博客网 时间:2024/05/29 17:42
/* Copyright DR.YangLong Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.*/package com.quancai.erp.utils;/** * functional describe:字符串相关工具类 */public class StringUtilTools { /** * 判断字符串是不是NULL或是空字符串,如果是,返回true,不是false * * @param str 待判断字符串 * @return true/false */ public static boolean isNullOrEmpty(final String str) { return str == null || "".equals(str); } /** * 判断字符串对象是不是NULL或空,如果是,返回true,不是false * @param str 字符串对象 * @return true/false */ public static boolean isNullOrEmpty(final Object str){ return str==null||"".equals(str.toString()); } /** * 对比2个对象的内容是否一致 * @param ob1 对象1 * @param ob2 对象2 * @return true/false */ public static boolean equalObject(Object ob1,Object ob2){ return !(ob1==null||ob2==null)&&ob1.equals(ob2); } /** * 对比2个String对象的内容是否一致,忽略大小写 * @param ob1 对象1 * @param ob2 对象2 * @return true/false */ public static boolean equalStringObjectIgnoreCase(Object ob1,Object ob2){ return !(ob1==null||ob2==null)&&(ob1.toString().equalsIgnoreCase(ob2.toString())); } /** * * @param array 数组 * @param surffix 分割符号 * @return */ public static String array2String(final String[] array,final String surffix){ StringBuilder builder=new StringBuilder(); for(int i=0;i<array.length;i++){ if(i==array.length-1){ builder.append(array[i]); } else { builder.append(array[i]).append(surffix); } } return builder.toString(); } /** * 调用对象的toString方法,返回对象的字符串,如果是NULL返回null字符串 * @param o 对象 * @return String */ public static String wrapperNull(Object o){ if(o==null){ return "null"; } return o.toString(); }}
0 0
- 字符串和对象判空工具类
- 判空相关工具类
- 判空相关工具类
- 【JAVA基础】list和字符串判空
- Android EmptyUtils-判空相关工具类
- 字符串的判空
- Java字符串判空
- 字符串判空
- 字符串 判空
- 字符串判空问题
- 集合,字符串判空
- JAVA对象判空
- JavaScript对象判空
- js 对象判空
- js 对象判空
- javascript 对象判空
- Json{}对象判空
- 字符串String和list集合判空验证
- Leaflet+Geoserver+Oracle/Postgis项目搭建(二)
- python3配置pyMysql
- POJ3974 回文串。EXKMP模板和马拉车算法模板
- 宽字符处理函数函数与普通函数对照表
- Python基础-1
- 字符串和对象判空工具类
- Android中另一种对话框--PopUpWindow
- 数学定义与公式
- xpath如何取出被标签包含的文字内容?
- Set使用攻略
- springmvc项目,增加jdbc支持
- 制作带有 GRUB 引导功能的软盘镜像文件
- 如何从github上直接下载补丁
- 你写的 return null 正确吗?