OpenDaylight Controller functional modules.
[controller.git] / opendaylight / forwardingrulesmanager / src / main / java / org / opendaylight / controller / forwardingrulesmanager / PortGroup.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
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
8  */
9
10 package org.opendaylight.controller.forwardingrulesmanager;
11
12 import java.util.HashSet;
13 import java.util.Set;
14
15 /**
16  * PortGroup is a simple data-structure to represent any arbitrary group of ports
17  * on a Switch (that is represented using its switch-ID).
18  *
19  * PortGroup is used by PortGroupProvider application to signal a set of ports that
20  * represent a configured PortGroupConfig.
21  *
22  *
23  */
24 public class PortGroup {
25     private long matrixSwitchId;
26     private Set<Short> ports;
27
28     /**
29      * PortGroup Constructor using Switch and Ports.
30      *
31      * @param matrixSwitchId Switch Id that represents an openflow Switch
32      * @param ports Set of short values representing openflow port-ids.
33      */
34     public PortGroup(long matrixSwitchId, Set<Short> ports) {
35         super();
36         this.matrixSwitchId = matrixSwitchId;
37         this.ports = ports;
38     }
39
40     /**
41      * PortGroup Constructor using Switch.
42      *
43      * @param matrixSwitchId 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 Switch-Id that represents an openflow Switch
63      */
64     public void setMatrixSwitchId(long matrixSwitchId) {
65         this.matrixSwitchId = matrixSwitchId;
66     }
67
68     /**
69      * Returns the Set of Ports that makes this PortGroup.
70      *
71      * @return Set of short values representing openflow port-ids.
72      */
73     public Set<Short> getPorts() {
74         return ports;
75     }
76
77     /**
78      * Assigns a set of openflow ports to this PortGroup
79      *
80      * @param ports Set of short values representing openflow port-ids.
81      */
82     public void setPorts(Set<Short> ports) {
83         this.ports = ports;
84     }
85
86     /**
87      * Adds a port to this PortGroup
88      *
89      * @param port Short value of a openflow port.
90      */
91     public void addPort(short port) {
92         ports.add(port);
93     }
94
95     @Override
96     public String toString() {
97         return "PortGroup [matrixSwitchId=" + matrixSwitchId + ", ports="
98                 + ports + "]";
99     }
100 }