blob: 25c7295500af45f96a0e6dd82e7c1aaef6aaea25 [file] [log] [blame]
Rimon Ashkenazy8ebfff02016-02-01 11:56:36 +02001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Rimon Ashkenazy8ebfff02016-02-01 11:56:36 +02003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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 implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.net;
17
18import java.util.Objects;
19
20import static com.google.common.base.MoreObjects.toStringHelper;
21
22/**
23 * Implementation of OTU port (Optical channel Transport Unit).
24 */
25
26public class OtuPort extends DefaultPort {
27
28 private final OtuSignalType signalType;
29
30 /**
31 * Creates an OTU port in the specified network element.
32 *
33 * @param element parent network element
34 * @param number port number
35 * @param isEnabled port enabled state
36 * @param signalType OTU signal type
37 * @param annotations optional key/value annotations
38 */
39 public OtuPort(Element element, PortNumber number, boolean isEnabled,
40 OtuSignalType signalType, Annotations... annotations) {
41 super(element, number, isEnabled, Type.OTU, 0, annotations);
42 this.signalType = signalType;
43 }
44
45 /**
46 * Returns OTU signal type.
47 *
48 * @return OTU signal type
49 */
50 public OtuSignalType signalType() {
51 return signalType;
52 }
53
54 @Override
55 public int hashCode() {
56 return Objects.hash(number(), isEnabled(), type(), signalType, annotations());
57 }
58
59 @Override
60 public boolean equals(Object obj) {
61 if (this == obj) {
62 return true;
63 }
64 if (obj instanceof OtuPort) {
65 final OtuPort other = (OtuPort) obj;
66 return Objects.equals(this.element().id(), other.element().id()) &&
67 Objects.equals(this.number(), other.number()) &&
68 Objects.equals(this.isEnabled(), other.isEnabled()) &&
69 Objects.equals(this.signalType, other.signalType) &&
70 Objects.equals(this.annotations(), other.annotations());
71 }
72 return false;
73 }
74
75
76 @Override
77 public String toString() {
78 return toStringHelper(this)
79 .add("element", element().id())
80 .add("number", number())
81 .add("isEnabled", isEnabled())
82 .add("type", type())
83 .add("signalType", signalType)
84 .toString();
85 }
86
87}