I have the following Java code which I want to migrate to latest Java code:
package com.mapr.org.apache.hadoop.hbase.util.CollectionUtils
.....
if (CollectionUtils.notEmpty(users)) {
....
}
Content of CollectionUtils from old mapr maven dependency:
package com.mapr.org.apache.hadoop.hbase.util;
public class CollectionUtils {
private static final List<Object> EMPTY_LIST = Collections.unmodifiableList(new ArrayList(0));
public CollectionUtils() {
}
.....
public static <A, B> boolean nullSafeSameSize(Collection<A> a, Collection<B> b) {
return nullSafeSize(a) == nullSafeSize(b);
}
public static <T> boolean isEmpty(Collection<T> collection) {
return collection == null || collection.isEmpty();
}
public static <T> boolean notEmpty(Collection<T> collection) {
return !isEmpty(collection);
}
public static <T> T getFirst(Collection<T> collection) {
if (isEmpty(collection)) {
return null;
} else {
Iterator var1 = collection.iterator();
if (var1.hasNext()) {
T t = var1.next();
return t;
} else {
return null;
}
}
}
public static int getLastIndex(List<?> list) {
return isEmpty(list) ? -1 : list.size() - 1;
}
public static boolean isLastIndex(List<?> list, int index) {
return index == getLastIndex(list);
}
public static <T> T getLast(List<T> list) {
return isEmpty(list) ? null : list.get(list.size() - 1);
}
}
Do you know how I can migrate CollectionUtils.notEmpty(....)
to latest Java version?
I want to remove hadoop dependency form the project.