//新BaseModel須要繼承Model<T>app
public class BaseModel<M extends Model<M>> extends Model<M> {ui
private Map<String, Object> attrs = getAttrs();
/**
* 傳入參數
* @Title: setOtherAttr
* @Description: TODO(這裏用一句話描述這個方法的做用)
* @param @param key
* @param @param value 設定文件
* @return void 返回類型
* @throws
*/
public void setOtherAttr(String key,Object value){
attrs.put(key, value);
}
/**
* 獲取參數
* @Title: getMyAttrs
* @Description: TODO(這裏用一句話描述這個方法的做用)
* @param @return 設定文件
* @return Map<String,Object> 返回類型
* @throws
*/
public Map<String, Object> getMyAttrs(){
return attrs;
}
public Object getMyAttr(String key){
return attrs.get(key);
}
/**
* 重寫TOString
*/
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
boolean first = true;
for (Entry<String, Object> e : attrs.entrySet()) {
if (first)
first = false;
else
sb.append(", ");
Object value = e.getValue();
if (value != null)
value = value.toString();
sb.append(e.getKey()).append(":").append(value);
}
sb.append("}");
return sb.toString();
}
}.net