欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Ibatis通用对象封装

程序员文章站 2022-05-23 12:55:25
...

public class MapBean extends HashMap<String, Object> {
public MapBean() {
}

public MapBean(Object... args) {
put(args);
}

public int getInt(Object key) {
return getInt(key, 0);
}

public int getInt(Object key, int defaultInt) {
Integer i = (Integer) get(key);
return i == null ? defaultInt : i;
}

public String getString(Object key) {
return (String) get(key);
}

public String getString(Object key, String defaultValue) {
String value = (String) get(key);
return value == null ? defaultValue : value;
}

public Timestamp getTimestamp(Object key) {
return (Timestamp) get(key);
}

public void put(Object... args) {
for (int i = 1; i < args.length; i += 2) {
put(String.valueOf(args[i - 1]), args[i]);
}
}

public JSONObject toJson() {
return JSONObject.fromObject(this);
}

public JSONObject toJson(String... keys) {
xxx
}

public String toJsonString() {
return toJson().toString();
}
}
相关标签: iBATIS