61 lines
1015 B
Java
Raw Normal View History

2024-05-31 18:47:42 +08:00
package com.zhgd.xmgl.util;
import com.alibaba.fastjson.JSONObject;
/**
* 一个简单的JSONObject构建器
*/
public class JoBuilder {
private JSONObject jsonObject;
/**
* 默认构造函数
*/
public JoBuilder() {
jsonObject = new JSONObject();
}
/**
* 有参构造函数
*
* @param jsonObject
*/
public JoBuilder(JSONObject jsonObject) {
this.jsonObject = jsonObject;
}
/**
* put方法返回MapParamBuilder构建器
*
* @param key
* @param value
* @return
*/
public JoBuilder put(String key, Object value) {
jsonObject.put(key, value);
return this;
}
/**
* 删除Key
*
* @param key
* @return
*/
public JoBuilder remove(String key) {
jsonObject.remove(key);
return this;
}
/**
* 返回构建好的map参数
*
* @return
*/
public JSONObject build() {
return jsonObject;
}
}