2024-10-12 00:57:35 +08:00
|
|
|
/*
|
|
|
|
* Copyright 2023-2024 the original author or authors.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
* https://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.
|
|
|
|
*/
|
|
|
|
|
2024-02-07 09:27:42 +08:00
|
|
|
package xyz.zhouxy.plusone.commons.collection;
|
2023-04-29 18:38:14 +08:00
|
|
|
|
|
|
|
import java.util.Collection;
|
2023-06-03 23:58:53 +08:00
|
|
|
import java.util.Map;
|
2023-04-29 18:38:14 +08:00
|
|
|
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
2024-02-07 09:27:42 +08:00
|
|
|
public class CollectionTools {
|
2023-06-03 23:58:53 +08:00
|
|
|
|
|
|
|
// isEmpty
|
|
|
|
|
2023-04-29 18:38:14 +08:00
|
|
|
public static boolean isEmpty(@Nullable Collection<?> collection) {
|
|
|
|
return collection == null || collection.isEmpty();
|
|
|
|
}
|
|
|
|
|
2023-06-03 23:58:53 +08:00
|
|
|
public static boolean isEmpty(@Nullable Map<?, ?> map) {
|
|
|
|
return map == null || map.isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
// isNotEmpty
|
|
|
|
|
2023-04-29 18:38:14 +08:00
|
|
|
public static boolean isNotEmpty(@Nullable Collection<?> collection) {
|
|
|
|
return collection != null && !collection.isEmpty();
|
|
|
|
}
|
|
|
|
|
2023-06-03 23:58:53 +08:00
|
|
|
public static boolean isNotEmpty(@Nullable Map<?, ?> map) {
|
|
|
|
return map != null && !map.isEmpty();
|
|
|
|
}
|
|
|
|
|
2024-02-07 09:27:42 +08:00
|
|
|
private CollectionTools() {
|
2023-04-29 18:38:14 +08:00
|
|
|
throw new IllegalStateException("Utility class");
|
|
|
|
}
|
|
|
|
}
|