package com.sitechasia.ebiz.publics.model; import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; import org.apache.commons.lang.StringUtils; public class StatisticsDO { private Integer id; private int vpCount1; private int vpCount2; private transient Map<String, Integer> vpCount = new HashMap<String, Integer>(); public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public int getVpCount1() { return vpCount1; } public void setVpCount1(int vpCount1) { this.vpCount1 = vpCount1; vpCount.put("vpCount1", vpCount1); } public int getVpCount2() { return vpCount2; } public void setVpCount2(int vpCount2) { this.vpCount2 = vpCount2; vpCount.put("vpCount2", vpCount2); } public int getVpCount(String type) { return vpCount.get(type); } public void setVpCount(String field, int value) { try { if (StringUtils.isNotBlank(field) && field.startsWith("vpCount")) { String methodName = "set" + field.replaceFirst("v", "V"); Class<Integer> argType = int.class; Method method = this.getClass().getMethod(methodName, argType); method.invoke(this, (Object) value); } } catch (Exception e) { e.printStackTrace(); } } }
method.invoke运用
猜你喜欢
转载自chenjie1121.iteye.com/blog/2220091
今日推荐
周排行