blob: 08bb943844f75355902e30d35c4d37d32acafaa6 [file] [log] [blame]
Marc De Leenheerbb382352015-04-23 18:20:34 -07001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
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;
Toru Furusawa0f5da692016-01-07 14:51:47 -080021import static com.google.common.base.Preconditions.checkNotNull;
Marc De Leenheerbb382352015-04-23 18:20:34 -070022
23/**
24 * Implementation of ODU client port (Optical channel Data Unit).
25 * Also referred to as a T-port or wide band port.
26 * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
27 */
28
29public class OduCltPort extends DefaultPort {
30
31 public enum SignalType {
32 CLT_1GBE,
33 CLT_10GBE,
34 CLT_40GBE,
35 CLT_100GBE
36 }
37
38 private final SignalType signalType;
39
40
41 /**
42 * Creates an ODU client port in the specified network element.
43 *
44 * @param element parent network element
45 * @param number port number
46 * @param isEnabled port enabled state
47 * @param signalType ODU client signal type
48 * @param annotations optional key/value annotations
49 */
50 public OduCltPort(Element element, PortNumber number, boolean isEnabled,
51 SignalType signalType, Annotations... annotations) {
52 super(element, number, isEnabled, Type.ODUCLT, 0, annotations);
Toru Furusawa0f5da692016-01-07 14:51:47 -080053 this.signalType = checkNotNull(signalType);
Marc De Leenheerbb382352015-04-23 18:20:34 -070054 }
55
56 /**
57 * Returns ODU client signal type.
58 *
59 * @return ODU client signal type
60 */
61 public SignalType signalType() {
62 return signalType;
63 }
64
65 @Override
66 public int hashCode() {
67 return Objects.hash(number(), isEnabled(), type(), signalType, annotations());
68 }
69
70 @Override
71 public boolean equals(Object obj) {
72 if (this == obj) {
73 return true;
74 }
Satish K7cfdc632015-11-27 19:48:41 +053075 if (obj != null && getClass() == obj.getClass()) {
Marc De Leenheerbb382352015-04-23 18:20:34 -070076 final OduCltPort other = (OduCltPort) obj;
77 return Objects.equals(this.element().id(), other.element().id()) &&
78 Objects.equals(this.number(), other.number()) &&
79 Objects.equals(this.isEnabled(), other.isEnabled()) &&
80 Objects.equals(this.signalType, other.signalType) &&
81 Objects.equals(this.annotations(), other.annotations());
82 }
83 return false;
84 }
85
86
87 @Override
88 public String toString() {
89 return toStringHelper(this)
90 .add("element", element().id())
91 .add("number", number())
92 .add("isEnabled", isEnabled())
93 .add("type", type())
94 .add("signalType", signalType)
95 .toString();
96 }
97
98}