美文网首页
判断对象是否为空

判断对象是否为空

作者: 哼哼_faf8 | 来源:发表于2020-07-10 17:10 被阅读0次

    public class EmptyUtils {

    public OrganizationEntity  dealIsNull(OrganizationEntity entity) {

    if (isEmpty(entity.getAreaID()) ) {

    entity.setAreaID("");

    }

    return entity;

    }

    public static boolean isEmpty(Object obj){

    if (obj ==null)

    return true;

    if (objinstanceof CharSequence)

    return ((CharSequence) obj).length() ==0;

    if (objinstanceof Collection)

    return ((Collection) obj).isEmpty();

    if (objinstanceof Map)

    return ((Map) obj).isEmpty();

    if (objinstanceof Object[]) {

    Object[] object = (Object[]) obj;

    if (object.length ==0) {

    return true;

    }

    boolean empty =true;

    for (int i =0; i < object.length; i++) {

    if (!isEmpty(object[i])) {

    empty =false;

    break;

    }

    }

    return empty;

    }

    return false;

    }

    public static boolean isNotEmpty(Object obj){

    return !isEmpty(obj);

    }

    private boolean validPropertyEmpty(Object ...args) {

    for (int i =0; i < args.length; i++) {

    if(EmptyUtils.isEmpty(args[i])){

    return true;

    }

    }

    return false;

    }

    }

    相关文章

      网友评论

          本文标题:判断对象是否为空

          本文链接:https://www.haomeiwen.com/subject/fovmcktx.html