001/*
002 *  Copyright (c) 2022-2025, Mybatis-Flex (fuhai999@gmail.com).
003 *  <p>
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *  <p>
008 *  http://www.apache.org/licenses/LICENSE-2.0
009 *  <p>
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package com.mybatisflex.core.query;
017
018import com.mybatisflex.core.util.StringUtil;
019
020import java.util.Collection;
021import java.util.Map;
022
023public class If {
024
025    private If() {
026    }
027
028    /**
029     * 判断对象是否为空
030     */
031    public static boolean isNull(Object object) {
032        return object == null;
033    }
034
035    /**
036     * 判断对象是否非空
037     */
038    public static boolean notNull(Object object) {
039        return object != null;
040    }
041
042    public static <T> boolean isEmpty(T[] array) {
043        return array != null && array.length == 0;
044    }
045
046    public static <T> boolean isNotEmpty(T[] array) {
047        return !isEmpty(array);
048    }
049
050    public static boolean isEmpty(Map<?, ?> map) {
051        return map != null && map.isEmpty();
052    }
053
054    public static boolean isNotEmpty(Map<?, ?> map) {
055        return !isEmpty(map);
056    }
057
058    public static boolean isEmpty(Collection<?> collection) {
059        return collection != null && collection.isEmpty();
060    }
061
062    public static boolean isNotEmpty(Collection<?> collection) {
063        return !isEmpty(collection);
064    }
065
066    /**
067     * 查看某个 string 对象是否有文本内容
068     */
069    public static boolean hasText(String string) {
070        return StringUtil.isNotBlank(string);
071    }
072
073}