Android Open Source - json2view Dynamic Property Json Builder






From Project

Back to project page json2view.

License

The source code is released under:

MIT License

If you think the Android project json2view listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.avocarrot.json2view;
/*from   ww  w  .  j  av  a  2s . c  o m*/
import android.util.Log;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class DynamicPropertyJsonBuilder {

    private String name;
    private String type;
    private String value;

    public DynamicPropertyJsonBuilder() {}

    public DynamicPropertyJsonBuilder setName(DynamicProperty.NAME name) {
        this.name = name.toString();
        return this;
    }
    public DynamicPropertyJsonBuilder setType(DynamicProperty.TYPE type) {
        this.type = type.toString();
        return this;
    }
    public DynamicPropertyJsonBuilder setValue(Object value) {
        this.value = value.toString();
        return this;
    }

    public JSONObject build() {
        Map<String, Object> map = new HashMap<>();
        map.put("name", name);
        map.put("type", type);
        map.put("value", value);
        return new JSONObject(map);
    }

}




Java Source Code List

com.avocarrot.json2view.ApplicationTest.java
com.avocarrot.json2view.DynamicHelper.java
com.avocarrot.json2view.DynamicPropertyJsonBuilder.java
com.avocarrot.json2view.DynamicProperty.java
com.avocarrot.json2view.DynamicViewId.java
com.avocarrot.json2view.DynamicViewJsonBuilder.java
com.avocarrot.json2view.DynamicView.java
com.avocarrot.json2view.TestActivity.java
com.avocarrot.json2view.TestImageViewPropertiesCase.java
com.avocarrot.json2view.TestInvalidJson.java
com.avocarrot.json2view.TestLayoutPropertiesCase.java
com.avocarrot.json2view.TestSampleCase.java
com.avocarrot.json2view.TestViewPropertiesCase.java
com.avocarrot.json2view.Utils.java
com.avocarrot.json2view.sample.MainActivity.java