标签:string port factory lse frame eth orm logger public
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.lang.reflect.Method;
@Component
public class SetPlatformUtils {
private static final CoreServiceType c = CoreServiceType.getInstance();
public void setVal(Object obj, String methodName, String platform){
//获取obj代表的实体类class对象
Class clazz = obj.getClass();
Method method = null;
try {
//获取class对象中的指定的方法
method = clazz.getMethod(methodName, String.class);
//给方法赋值
if (StringUtils.isBlank(platform)){
method.invoke(obj,c.CODE.get("1"));
}else{
method.invoke(obj, c.CODE.get(platform));
}
}
catch (Exception e) {
logger.error("存储二级分类的反射工具类出错,obj:{},methodName:{},platform:{},",obj,methodName,platform);
}
}
}
标签:string port factory lse frame eth orm logger public
原文地址:https://www.cnblogs.com/bin-zhao/p/11609374.html