com.github.dingey.common.BaseFallback Maven / Gradle / Ivy
package com.github.dingey.common;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.objenesis.instantiator.util.ClassUtils;
import org.springframework.util.StringUtils;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@SuppressWarnings("unchecked")
public abstract class BaseFallback {
private final Logger log = LoggerFactory.getLogger(this.getClass());
private static final HashMap genericProp = new HashMap<>();
public T fallback(Object... args) {
error(args);
return (T) empty();
}
public StackTraceElement getTrace() {
return getTrace(5);
}
public StackTraceElement getErrorTrace() {
return getTrace(6);
}
public StackTraceElement getTrace(int index) {
StackTraceElement[] traces = Thread.currentThread().getStackTrace();
return traces[index];
}
public void error(Object... args) {
error(null, args);
}
public void error(Throwable cause, Object... args) {
StackTraceElement trace = getErrorTrace();
String methodName = trace.getMethodName();
Class
© 2015 - 2025 Weber Informatics LLC | Privacy Policy