com.yixan.tools.common.sync.Callback Maven / Gradle / Ivy
package com.yixan.tools.common.sync;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.yixan.tools.common.util.ReflectUtil;
/**
* 回调接口
*
* public static interface Sync {
* public static Callback<Void> Void = new Callback.Log<>();
* public static Callback<Integer> Integer = new Callback.Log<>();
* public static Callback<String> String = new Callback.Log<>();
* public static Callback<XxxData> XxxData = new Callback.Log<>();
* public static Callback<List<XxxData>> XxxList = new Callback.Log<>();
* }
*
*
* @author zhaohuihua
* @version V1.0 2017-09-18
*/
public interface Callback {
void done(T result);
void fail(Object object, String method, Args args, Throwable e);
public static class Ignore implements Callback {
@Override
public void done(T result) {
}
@Override
public void fail(Object object, String method, Args args, Throwable e) {
}
}
public static class Log implements Callback {
@Override
public void done(T result) {
}
@Override
public void fail(Object object, String method, Args args, Throwable e) {
Logger log = LoggerFactory.getLogger(object.getClass());
String signature = ReflectUtil.getMethodLogSignature(object.getClass(), method, args.types());
log.warn("Sync invoke {} error. {}:{}", signature, e.getClass().getSimpleName(), e.getMessage(), e);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy