org.eclipse.edc.util.collection.CollectionUtil Maven / Gradle / Ivy
/*
* Copyright (c) 2020, 2021 Microsoft Corporation
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Microsoft Corporation - initial API and implementation
*
*/
package org.eclipse.edc.util.collection;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
public class CollectionUtil {
public static boolean isEmpty(Collection collection) {
return collection == null || collection.isEmpty();
}
public static boolean isNotEmpty(Collection collection) {
return !isEmpty(collection);
}
public static boolean isNotEmpty(Map map) {
return !isEmpty(map);
}
private static boolean isEmpty(Map map) {
return map == null || map.isEmpty();
}
public static boolean isAnyOf(T t, T... collection) {
if (collection == null) {
return false;
}
return Arrays.asList(collection).contains(t);
}
}