BUG 2302 : odl-clustering-test-app should not be part of the odl-restconf-all feature set
[controller.git] / opendaylight / adsal / forwardingrulesmanager / api / src / main / java / org / opendaylight / controller / forwardingrulesmanager / PortGroup.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.forwardingrulesmanager;
10
11 import java.util.HashSet;
12 import java.util.Set;
13
14 /**
15  * PortGroup is a simple data-structure to represent any arbitrary group of
16  * ports on a Switch (that is represented using its switch-ID).
17  *
18  * PortGroup is used by PortGroupProvider application to signal a set of ports
19  * that represent a configured PortGroupConfig.
20  */
21 public class PortGroup {
22     private long matrixSwitchId;
23     private Set<Short> ports;
24
25     /**
26      * PortGroup Constructor using Switch and Ports.
27      *
28      * @param matrixSwitchId
29      *            Switch Id that represents an openflow Switch
30      * @param ports
31      *            Set of short values representing openflow port-ids.
32      */
33     public PortGroup(long matrixSwitchId, Set<Short> ports) {
34         super();
35         this.matrixSwitchId = matrixSwitchId;
36         this.ports = ports;
37     }
38
39     /**
40      * PortGroup Constructor using Switch.
41      *
42      * @param matrixSwitchId
43      *            Switch-Id that represents an openflow Switch
44      */
45     public PortGroup(long matrixSwitchId) {
46         this.matrixSwitchId = matrixSwitchId;
47         this.ports = new HashSet<Short>();
48     }
49
50     /**
51      * Returns the switchId representing the Switch that makes this PortGroup.
52      *
53      * @return long switchId
54      */
55     public long getMatrixSwitchId() {
56         return matrixSwitchId;
57     }
58
59     /**
60      * Assigns a Switch to this PortGroup
61      *
62      * @param matrixSwitchId
63      *            Switch-Id that represents an openflow Switch
64      */
65     public void setMatrixSwitchId(long matrixSwitchId) {
66         this.matrixSwitchId = matrixSwitchId;
67     }
68
69     /**
70      * Returns the Set of Ports that makes this PortGroup.
71      *
72      * @return Set of short values representing openflow port-ids.
73      */
74     public Set<Short> getPorts() {
75         return ports;
76     }
77
78     /**
79      * Assigns a set of openflow ports to this PortGroup
80      *
81      * @param ports
82      *            Set of short values representing openflow port-ids.
83      */
84     public void setPorts(Set<Short> ports) {
85         this.ports = ports;
86     }
87
88     /**
89      * Adds a port to this PortGroup
90      *
91      * @param port
92      *            Short value of a openflow port.
93      */
94     public void addPort(short port) {
95         ports.add(port);
96     }
97
98     @Override
99     public String toString() {
100         return "PortGroup [matrixSwitchId=" + matrixSwitchId + ", ports=" + ports + "]";
101     }
102 }