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    @Deprecated
047    public static <T> boolean isNotEmpty(T[] array) {
048        return notEmpty(array);
049    }
050
051    public static <T> boolean notEmpty(T[] array) {
052        return !isEmpty(array);
053    }
054
055    public static boolean isEmpty(Map<?, ?> map) {
056        return map == null || map.isEmpty();
057    }
058
059    @Deprecated
060    public static boolean isNotEmpty(Map<?, ?> map) {
061        return notEmpty(map);
062    }
063
064    public static boolean notEmpty(Map<?, ?> map) {
065        return !isEmpty(map);
066    }
067
068    public static boolean isEmpty(Collection<?> collection) {
069        return collection == null || collection.isEmpty();
070    }
071
072    @Deprecated
073    public static boolean isNotEmpty(Collection<?> collection) {
074        return notEmpty(collection);
075    }
076
077    public static boolean notEmpty(Collection<?> collection) {
078        return !isEmpty(collection);
079    }
080
081    public static boolean hasText(String string) {
082        return StringUtil.hasText(string);
083    }
084
085    public static boolean noText(String string) {
086        return StringUtil.noText(string);
087    }
088
089}