private void initLocalController() { NodeBuilder nodeBuilder = new NodeBuilder(); NodeId nodeId = new NodeId(localHostName); localController = nodeBuilder.setNodeType(NODE_TYPE_CONTROLLER).setNodeId(nodeId).setKey(new NodeKey(nodeId)) .build(); }
public NodeBuilder addAugmentation(java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.usc.channel.rev150101.topology.attributes.Node>> augmentationType, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.usc.channel.rev150101.topology.attributes.Node> augmentation) { if (augmentation == null) { return removeAugmentation(augmentationType); } if (!(this.augmentation instanceof HashMap)) { this.augmentation = new HashMap<>(); } this.augmentation.put(augmentationType, augmentation); return this; }
private NodeImpl(NodeBuilder base) { if (base.getKey() == null) { this._key = new NodeKey( base.getNodeId() ); this._nodeId = base.getNodeId(); } else { this._key = base.getKey(); this._nodeId = _key.getNodeId(); } this._nodeType = base.getNodeType(); switch (base.augmentation.size()) { case 0: this.augmentation = Collections.emptyMap(); break; case 1: final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.usc.channel.rev150101.topology.attributes.Node>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.usc.channel.rev150101.topology.attributes.Node>> e = base.augmentation.entrySet().iterator().next(); this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.usc.channel.rev150101.topology.attributes.Node>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.usc.channel.rev150101.topology.attributes.Node>>singletonMap(e.getKey(), e.getValue()); break; default : this.augmentation = new HashMap<>(base.augmentation); } }
/** * Builds a node for the provided id. Passes node attributes to NodeBuilder * to build a node. * * @param id * node id * @param type * node type * @return new node */ public static Node createNode(String id, String type) { NodeId nodeId = new NodeId(id); NodeKey nodeKey = new NodeKey(nodeId); NodeBuilder nodeBuilder = new NodeBuilder(); nodeBuilder.setNodeId(nodeId); nodeBuilder.setKey(nodeKey); nodeBuilder.setNodeType(type); return nodeBuilder.build(); }