3 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
10 package org.opendaylight.controller.sal.utils;
12 import java.util.HashSet;
15 import org.opendaylight.controller.sal.core.ConstructionException;
16 import org.opendaylight.controller.sal.core.Node;
17 import org.opendaylight.controller.sal.core.NodeConnector;
18 import org.opendaylight.controller.sal.core.Node.NodeIDType;
19 import org.opendaylight.controller.sal.core.NodeConnector.NodeConnectorIDType;
22 * The class provides helper functions to create a node connector
26 public abstract class NodeConnectorCreator {
28 * Generic NodeConnector creator
29 * The nodeConnector type is inferred from the node type
35 public static NodeConnector createNodeConnector(Object portId, Node node) {
36 if (node.getType().equals(NodeIDType.OPENFLOW)) {
38 return new NodeConnector(NodeConnectorIDType.OPENFLOW,
39 (Short) portId, node);
40 } catch (ConstructionException e1) {
49 * NodeConnector creator where NodeConnector type can be specified
50 * Needed to create special internal node connectors (like software stack)
52 * @param nodeConnectorType
57 public static NodeConnector createNodeConnector(
58 String nodeConnectorType, Object portId, Node node) {
60 return new NodeConnector(nodeConnectorType, portId, node);
61 } catch (ConstructionException e1) {
67 public static NodeConnector createOFNodeConnector(Short portId, Node node) {
69 return new NodeConnector(NodeConnectorIDType.OPENFLOW, portId, node);
70 } catch (ConstructionException e1) {
76 public static Set<NodeConnector> createOFNodeConnectorSet(
77 Set<Short> portIds, Node n) {
79 Set<NodeConnector> nodeConnectors = new HashSet<NodeConnector>();
80 for (Short ofPortID : portIds) {
81 NodeConnector p = new NodeConnector(
82 NodeConnector.NodeConnectorIDType.OPENFLOW, Short
83 .valueOf(ofPortID), n);
84 nodeConnectors.add(p);
86 return nodeConnectors;
87 } catch (ConstructionException e1) {