2024-05-31 18:47:42 +08:00

61 lines
1015 B
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
}
}