use of org.onosproject.net.ChannelSpacing 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);
}
Aggregations