Reference Guide
Table Of Contents
- 1 Introduction
- 2 Establishing Your Test and Development Environments
- 3 Developing Applications
- Introduction
- Authentication
- REST API
- Audit Logging
- Alert Logging
- Configuration
- High Availability
- OpenFlow
- Metrics Framework
- GUI
- SKI Framework - Overview
- SKI Framework - Navigation Tree
- SKI Framework - Hash Navigation
- SKI Framework - View Life-Cycle
- SKI Framework - Live Reference Application
- UI Extension
- Introduction
- Controller Teaming
- Distributed Coordination Service
- Persistence
- Backup and Restore
- Device Driver Framework
- 4 Application Security
- 5 Including Debian Packages with Applications
- 6 Sample Application
- Application Description
- Creating Application Development Workspace
- Application Generator (Automatic Workspace Creation)
- Creating Eclipse Projects
- Updating Project Dependencies
- Building the Application
- Installing the Application
- Application Code
- 7 Testing Applications
- 8 Built-In Applications
- Appendix A
- Appendix B
- Bibliography
package com.hp.hm.rs.json;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.hp.util.json.AbstractJsonCodec;
import com.hp.util.json.JsonCodec;
...
public class SwitchJsonCodec extends AbstractJsonCodec<Switch> {
private static final String ID = "id";
private static final String MAC_ADDRESS = "mac_address";
private static final String IP_ADDRESS = "ip_address";
private static final String FRIENDLY_NAME = "friendly_name";
private static final String ACTIVE_STATE = "active_state";
public SwitchJsonCodec() {
super("switch", "switches");
}
@Override
public Switch decode(ObjectNode node) {
validateMandatoryFields(node, MAC_ADDRESS);
MacAddress macAddress = MacAddress.valueOf(
node.get(MAC_ADDRESS).asText());
Id<Switch, Long> id = null;
if (!node.path(ID).isMissingNode()) {
id = Id.valueOf(Long.valueOf(node.get(ID).asLong()));
}
Switch device = new Switch(id, macAddress);
if (!node.path(IP_ADDRESS).isMissingNode()) {
device.setIpAddress(IpAddress
.valueOf(node.get(IP_ADDRESS).asText()));
}
if (!node.path(FRIENDLY_NAME).isMissingNode()) {
device.setFriendlyName(node.get(FRIENDLY_NAME).asText());
}
if (!node.path(ACTIVE_STATE).isMissingNode()) {
device.setActiveState(ActiveState.valueOf(
node.get(ACTIVE_STATE).asText()));
}
184