com.github.wz2cool.elasticsearch.helper.CommonsHelper Maven / Gradle / Ivy
package com.github.wz2cool.elasticsearch.helper;
import com.github.wz2cool.elasticsearch.lambda.GetPropertyFunction;
import com.github.wz2cool.elasticsearch.model.PropertyInfo;
import java.lang.invoke.SerializedLambda;
import java.lang.reflect.Array;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author Frank
*/
@SuppressWarnings("all")
public class CommonsHelper {
private static ConcurrentHashMap classMap = new ConcurrentHashMap<>();
private CommonsHelper() {
throw new UnsupportedOperationException();
}
public static boolean isNumeric(final Class targetClass) {
if (targetClass == null) {
return false;
}
return Number.class.isAssignableFrom(targetClass);
}
public static boolean isArrayOrCollection(final Object value) {
return isArray(value) || isCollection(value);
}
public static boolean isArray(final Object value) {
return value != null && value.getClass().isArray();
}
public static boolean isCollection(final Object value) {
return value instanceof Iterable;
}
public static Object[] getCollectionValues(final Object inputValue) {
if (inputValue == null) {
throw new NullPointerException("inputValue");
}
if (!isArrayOrCollection(inputValue)) {
throw new IllegalArgumentException("inputValue should be array or collection");
}
Collection
© 2015 - 2024 Weber Informatics LLC | Privacy Policy