com.github.wz2cool.dynamic.helper.CommonsHelper Maven / Gradle / Ivy
package com.github.wz2cool.dynamic.helper;
import com.github.wz2cool.dynamic.exception.InternalRuntimeException;
import com.github.wz2cool.dynamic.lambda.GetPropertyFunction;
import com.github.wz2cool.dynamic.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
*/
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