package cn.axzo.msg.center.nimpush.payload.intent;

import cn.axzo.msg.center.common.utils.BizAssertions;
import com.alibaba.fastjson.JSONObject;

/**
 * @author yanglin
 */
public class JsonIntent implements Intent<JSONObject> {

    private final JSONObject values = new JSONObject();

    @Override
    public void setValue(String key, IntentValue value) {
        BizAssertions.assertNotBlank(key, "key is required");
        BizAssertions.assertNotNull(value, "value is required");
        value.consume(stringValue -> values.put(key, stringValue));
    }

    @Override
    public JSONObject build() {
        return values;
    }

}