Search in sources :

Example 1 with VariableStatus

use of com.optimizely.ab.config.LiveVariable.VariableStatus in project java-sdk by optimizely.

the class JsonSimpleConfigParser method parseLiveVariables.

private List<LiveVariable> parseLiveVariables(JSONArray liveVariablesJson) {
    List<LiveVariable> liveVariables = new ArrayList<LiveVariable>(liveVariablesJson.size());
    for (Object obj : liveVariablesJson) {
        JSONObject liveVariableObject = (JSONObject) obj;
        String id = (String) liveVariableObject.get("id");
        String key = (String) liveVariableObject.get("key");
        String defaultValue = (String) liveVariableObject.get("defaultValue");
        VariableType type = VariableType.fromString((String) liveVariableObject.get("type"));
        VariableStatus status = VariableStatus.fromString((String) liveVariableObject.get("status"));
        liveVariables.add(new LiveVariable(id, key, defaultValue, status, type));
    }
    return liveVariables;
}
Also used : VariableStatus(com.optimizely.ab.config.LiveVariable.VariableStatus) JSONObject(org.json.simple.JSONObject) VariableType(com.optimizely.ab.config.LiveVariable.VariableType) ArrayList(java.util.ArrayList) JSONObject(org.json.simple.JSONObject) LiveVariable(com.optimizely.ab.config.LiveVariable)

Example 2 with VariableStatus

use of com.optimizely.ab.config.LiveVariable.VariableStatus in project java-sdk by optimizely.

the class JsonConfigParser method parseLiveVariables.

private List<LiveVariable> parseLiveVariables(JSONArray liveVariablesJson) {
    List<LiveVariable> liveVariables = new ArrayList<LiveVariable>(liveVariablesJson.length());
    for (Object obj : liveVariablesJson) {
        JSONObject liveVariableObject = (JSONObject) obj;
        String id = liveVariableObject.getString("id");
        String key = liveVariableObject.getString("key");
        String defaultValue = liveVariableObject.getString("defaultValue");
        VariableType type = VariableType.fromString(liveVariableObject.getString("type"));
        VariableStatus status = null;
        if (liveVariableObject.has("status")) {
            status = VariableStatus.fromString(liveVariableObject.getString("status"));
        }
        liveVariables.add(new LiveVariable(id, key, defaultValue, status, type));
    }
    return liveVariables;
}
Also used : VariableStatus(com.optimizely.ab.config.LiveVariable.VariableStatus) JSONObject(org.json.JSONObject) VariableType(com.optimizely.ab.config.LiveVariable.VariableType) ArrayList(java.util.ArrayList) JSONObject(org.json.JSONObject) LiveVariable(com.optimizely.ab.config.LiveVariable)

Aggregations

LiveVariable (com.optimizely.ab.config.LiveVariable)2 VariableStatus (com.optimizely.ab.config.LiveVariable.VariableStatus)2 VariableType (com.optimizely.ab.config.LiveVariable.VariableType)2 ArrayList (java.util.ArrayList)2 JSONObject (org.json.JSONObject)1 JSONObject (org.json.simple.JSONObject)1