Revert "Checkstyle enforcer"
[controller.git] / opendaylight / 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  * 
22  */
23 public class PortGroup {
24     private long matrixSwitchId;
25     private Set<Short> ports;
26
27     /**
28      * PortGroup Constructor using Switch and Ports.
29      * 
30      * @param matrixSwitchId
31      *            Switch Id that represents an openflow Switch
32      * @param ports
33      *            Set of short values representing openflow port-ids.
34      */
35     public PortGroup(long matrixSwitchId, Set<Short> ports) {
36         super();
37         this.matrixSwitchId = matrixSwitchId;
38         this.ports = ports;
39     }
40
41     /**
42      * PortGroup Constructor using Switch.
43      * 
44      * @param matrixSwitchId
45      *            Switch-Id that represents an openflow Switch
46      */
47     public PortGroup(long matrixSwitchId) {
48         this.matrixSwitchId = matrixSwitchId;
49         this.ports = new HashSet<Short>();
50     }
51
52     /**
53      * Returns the switchId representing the Switch that makes this PortGroup.
54      * 
55      * @return long switchId
56      */
57     public long getMatrixSwitchId() {
58         return matrixSwitchId;
59     }
60
61     /**
62      * Assigns a Switch to this PortGroup
63      * 
64      * @param matrixSwitchId
65      *            Switch-Id that represents an openflow Switch
66      */
67     public void setMatrixSwitchId(long matrixSwitchId) {
68         this.matrixSwitchId = matrixSwitchId;
69     }
70
71     /**
72      * Returns the Set of Ports that makes this PortGroup.
73      * 
74      * @return Set of short values representing openflow port-ids.
75      */
76     public Set<Short> getPorts() {
77         return ports;
78     }
79
80     /**
81      * Assigns a set of openflow ports to this PortGroup
82      * 
83      * @param ports
84      *            Set of short values representing openflow port-ids.
85      */
86     public void setPorts(Set<Short> ports) {
87         this.ports = ports;
88     }
89
90     /**
91      * Adds a port to this PortGroup
92      * 
93      * @param port
94      *            Short value of a openflow port.
95      */
96     public void addPort(short port) {
97         ports.add(port);
98     }
99
100     @Override
101     public String toString() {
102         return "PortGroup [matrixSwitchId=" + matrixSwitchId + ", ports="
103                 + ports + "]";
104     }
105 }