From af85476c8249a307ff2d836d821d2187f24f5f8d Mon Sep 17 00:00:00 2001 From: Suomm <1474983351@qq.com> Date: Wed, 21 Jun 2023 19:01:05 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=E5=B7=A5=E5=85=B7=E7=B1=BB=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E7=A7=81=E6=9C=89=E6=9E=84=E9=80=A0=E5=99=A8=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/mybatisflex/core/query/If.java | 53 ++++++++++--------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/If.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/If.java index 86b35882..9bb95177 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/If.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/If.java @@ -1,17 +1,17 @@ -/** - * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). - *
- * 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. +/* + * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). + *
+ * 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.mybatisflex.core.query; @@ -24,11 +24,13 @@ import java.util.Map; public class If { + private If() { + } /** * 判断对象是否为空 */ - public static boolean isNull(Object object) { + public static boolean isNull(Object object) { return object == null; } @@ -41,26 +43,27 @@ public class If { /** * 查看某个对象是否为空,支持数组、集合、map 等 + * * @param object */ - public static boolean notEmpty(Object object){ - if (object == null){ + public static boolean notEmpty(Object object) { + if (object == null) { return false; } - if (object instanceof Collection){ + if (object instanceof Collection) { return !((Collection>) object).isEmpty(); } - if (ClassUtil.isArray(object.getClass())){ - return Array.getLength(object) >0; + if (ClassUtil.isArray(object.getClass())) { + return Array.getLength(object) > 0; } - if (object instanceof Map){ + if (object instanceof Map) { return !((Map, ?>) object).isEmpty(); } - if (object instanceof String){ + if (object instanceof String) { return StringUtil.isNotBlank((String) object); } return true; @@ -69,18 +72,20 @@ public class If { /** * 查看某个对象是否为空数据 或者 null + * * @param object */ - public static boolean isEmpty(Object object){ + public static boolean isEmpty(Object object) { return !notEmpty(object); } /** * 查看某个 string 对象是否有文本内容 + * * @param object */ - public static boolean hasText(Object object){ + public static boolean hasText(Object object) { return object != null && StringUtil.isNotBlank((String) object); }