Search in sources :

Example 11 with GridType

use of org.onosproject.net.GridType in project onos by opennetworkinglab.

the class OchSignalCodec method decode.

/**
 * Creates an instance of {@link OchSignal} from JSON representation.
 *
 * @param obj JSON Object representing OchSignal
 * @return OchSignal
 * @throws IllegalArgumentException - if JSON object is ill-formed
 * @see OchSignalCodec#encode(OchSignal)
 */
public static OchSignal decode(ObjectNode obj) {
    final GridType gridType;
    final ChannelSpacing channelSpacing;
    final int spacingMultiplier;
    final int slotGranularity;
    String s;
    s = obj.get("channelSpacing").textValue();
    checkArgument(s != null, "ill-formed channelSpacing");
    channelSpacing = Enum.valueOf(ChannelSpacing.class, s);
    s = obj.get("gridType").textValue();
    checkArgument(s != null, "ill-formed gridType");
    gridType = Enum.valueOf(GridType.class, s);
    JsonNode node;
    node = obj.get("spacingMultiplier");
    checkArgument(node.canConvertToInt(), "ill-formed spacingMultiplier");
    spacingMultiplier = node.asInt();
    node = obj.get("slotGranularity");
    checkArgument(node.canConvertToInt(), "ill-formed slotGranularity");
    slotGranularity = node.asInt();
    return new OchSignal(gridType, channelSpacing, spacingMultiplier, slotGranularity);
}
Also used : ChannelSpacing(org.onosproject.net.ChannelSpacing) OchSignal(org.onosproject.net.OchSignal) JsonNode(com.fasterxml.jackson.databind.JsonNode) GridType(org.onosproject.net.GridType)

Aggregations

ChannelSpacing (org.onosproject.net.ChannelSpacing)11 GridType (org.onosproject.net.GridType)11 OchSignal (org.onosproject.net.OchSignal)9 ConnectPoint (org.onosproject.net.ConnectPoint)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 LinkedHashSet (java.util.LinkedHashSet)2 Port (org.onosproject.net.Port)2 OchPort (org.onosproject.net.optical.OchPort)2 Frequency (org.onlab.util.Frequency)1 HexString (org.onlab.util.HexString)1 LambdaConfig (org.onosproject.driver.optical.config.LambdaConfig)1 NetworkConfigService (org.onosproject.net.config.NetworkConfigService)1