package org.apache.mesos.mini.state;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.json.JSONObject;

import java.awt.*;
import java.io.IOException;
import java.util.ArrayList;

/**
 * Created by peldan on 09/07/15.
 */
@JsonIgnoreProperties(ignoreUnknown = true)
public class State {


    public static State fromJSON(String jsonString) {
        ObjectMapper mapper = new ObjectMapper();
        try {
            return mapper.readValue(jsonString, State.class);
        } catch (IOException e) {
            throw new RuntimeException(e); // TODO throw something useful..
        }
    }

    public ArrayList<Framework> getFrameworks() {
        return frameworks;
    }

    public void setFrameworks(ArrayList<Framework> frameworks) {
        this.frameworks = frameworks;
    }

    private ArrayList<Framework> frameworks = new ArrayList<>();

    public Framework getFramework(String name) {
        for(Framework fw : getFrameworks()) {
            if (fw.getName().equals(name)) return fw;
        }
        return null;
    }
}

@@ -149,55 +149,8 @@
 er;%0A
-import org.json.JSONObject;%0A%0Aimport java.awt.*;
 %0Aimp
@@ -207,16 +207,113 @@
 t;%0A%0A/**%0A
+ * This class is populated with the results from a GET request to /state.json on a mesos-master.%0A
  * Creat
@@ -408,16 +408,129 @@
 tate %7B%0A%0A
+    // TODO this class should contain every field that is present in the JSON%0A    // add missing ones as needed%0A%0A
 %0A    pub

Add comment