Search in sources :

Example 1 with PortsDetail

use of org.openkilda.integration.model.PortsDetail in project open-kilda by telstra.

the class PortConverter method toPortsInfo.

/**
 * To ports info.
 *
 * @param jsonObject the json object
 * @param switchId the switch id
 * @return the list
 * @throws JsonParseException the json parse exception
 * @throws JsonMappingException the json mapping exception
 * @throws IOException Signals that an I/O exception has occurred.
 */
public static List<PortInfo> toPortsInfo(final JSONObject jsonObject, final String switchId) throws JsonParseException, JsonMappingException, IOException {
    List<PortInfo> ports = new ArrayList<PortInfo>();
    if (jsonObject != null) {
        Object object = jsonObject.get(switchId);
        if (object != null) {
            String val = JSONValue.toJSONString(object);
            PortsDetail portsDetail = JsonUtil.toObject(val, PortsDetail.class);
            List<PortDetail> portDetailList = portsDetail.getPortDetail();
            if (portDetailList != null && !portDetailList.isEmpty()) {
                ports = getPortsInfo(portDetailList, switchId, ports);
            }
        }
    }
    return ports;
}
Also used : PortInfo(org.openkilda.model.PortInfo) PortDetail(org.openkilda.integration.model.PortDetail) ArrayList(java.util.ArrayList) JSONObject(org.json.simple.JSONObject) PortsDetail(org.openkilda.integration.model.PortsDetail)

Aggregations

ArrayList (java.util.ArrayList)1 JSONObject (org.json.simple.JSONObject)1 PortDetail (org.openkilda.integration.model.PortDetail)1 PortsDetail (org.openkilda.integration.model.PortsDetail)1 PortInfo (org.openkilda.model.PortInfo)1