1 package org.opendaylight.nemo.tool.eclipse.plugin.rest.actions.model;
3 import org.json.JSONArray;
4 import org.json.JSONObject;
9 * Created by hj on 10/29/15.
11 public class Flow implements INemoItem {
12 private String flow_id;
13 private String flow_name;
14 private List<Match> matches;
15 public Flow(String flow_id, String flow_name, List<Match> matches) {
16 this.flow_id = flow_id;
17 this.flow_name = flow_name;
18 this.matches = matches;
22 public JSONObject toJSONObject() {
23 JSONObject flowJs = new JSONObject();
24 flowJs.put("flow-id", flow_id);
25 flowJs.put("flow-name", flow_name);
27 if (matches != null && matches.size() > 0) {
29 JSONArray jsonMatchArray = new JSONArray();
30 for (int i = 0; i < matches.size(); i++){
31 Match match = matches.get(i);
32 jsonMatchArray.put(i,match.toJSONObject());
34 flowJs.put("match-item",jsonMatchArray);
40 public boolean equals(Object o) {
41 if (this == o) return true;
42 if (o == null || getClass() != o.getClass()) return false;
46 if (flow_id != null ? !flow_id.equals(flow.flow_id) : flow.flow_id != null) return false;
52 public int hashCode() {
53 return flow_id != null ? flow_id.hashCode() : 0;
57 public String toString() {
59 "flow_id='" + flow_id + '\'' +
60 ", flow_name='" + flow_name + '\'' +
61 ", matches=" + matches +