2 * Copyright (c) 2012 Big Switch Networks, Inc.
4 * Licensed under the Eclipse Public License, Version 1.0 (the
5 * "License"); you may not use this file except in compliance with the
6 * License. You may obtain a copy of the License at
8 * http://www.eclipse.org/legal/epl-v10.html
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13 * implied. See the License for the specific language governing
14 * permissions and limitations under the License.
16 * This file incorporates work covered by the following copyright and
19 * Originally created by David Erickson, Stanford University
21 * Licensed under the Apache License, Version 2.0 (the "License");
22 * you may not use this file except in compliance with the
23 * License. You may obtain a copy of the License at
25 * http://www.apache.org/licenses/LICENSE-2.0
27 * Unless required by applicable law or agreed to in writing,
28 * software distributed under the License is distributed on an "AS
29 * IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
30 * express or implied. See the License for the specific language
31 * governing permissions and limitations under the License.
34 package org.opendaylight.controller.hosttracker;
36 import org.opendaylight.controller.sal.core.NodeConnector;
39 * A simple switch DPID/port pair This class is immutable
44 public class SwitchPort {
45 public enum ErrorStatus {
46 DUPLICATE_DEVICE("duplicate-device");
50 ErrorStatus(String v) {
55 public String toString() {
59 public static ErrorStatus fromString(String str) {
60 for (ErrorStatus m : ErrorStatus.values()) {
61 if (m.value.equals(str)) {
69 private final NodeConnector port;
70 private final ErrorStatus errorStatus;
80 * any error status for the switch port
82 public SwitchPort(NodeConnector port, ErrorStatus errorStatus) {
85 this.errorStatus = errorStatus;
96 public SwitchPort(NodeConnector port) {
99 this.errorStatus = null;
106 public NodeConnector getPort() {
110 public ErrorStatus getErrorStatus() {
119 public int hashCode() {
120 final int prime = 31;
122 result = prime * result
123 + ((errorStatus == null) ? 0 : errorStatus.hashCode());
124 result = prime * result + ((port == null) ? 0 : port.hashCode());
129 public boolean equals(Object obj) {
134 if (getClass() != obj.getClass())
136 SwitchPort other = (SwitchPort) obj;
137 if (errorStatus != other.errorStatus)
140 if (other.port != null)
142 } else if (!port.equals(other.port))
148 public String toString() {
149 return "SwitchPort [port=" + port + ", errorStatus=" + errorStatus