blob: 0f3a729da5b3f0f23327de2d717fadeb1a31f961 [file] [log] [blame]
Marc De Leenheerbb382352015-04-23 18:20:34 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Marc De Leenheerbb382352015-04-23 18:20:34 -07003 *
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
Toru Furusawa72ee30c2016-01-08 13:29:04 -080031 private final CltSignalType signalType;
Marc De Leenheerbb382352015-04-23 18:20:34 -070032
33 /**
34 * Creates an ODU client port in the specified network element.
35 *
36 * @param element parent network element
37 * @param number port number
38 * @param isEnabled port enabled state
39 * @param signalType ODU client signal type
40 * @param annotations optional key/value annotations
41 */
42 public OduCltPort(Element element, PortNumber number, boolean isEnabled,
Toru Furusawa72ee30c2016-01-08 13:29:04 -080043 CltSignalType signalType, Annotations... annotations) {
44 super(element, number, isEnabled, Type.ODUCLT, checkNotNull(signalType).bitRate(), annotations);
45 this.signalType = signalType;
Marc De Leenheerbb382352015-04-23 18:20:34 -070046 }
47
48 /**
49 * Returns ODU client signal type.
50 *
51 * @return ODU client signal type
52 */
Toru Furusawa72ee30c2016-01-08 13:29:04 -080053 public CltSignalType signalType() {
Marc De Leenheerbb382352015-04-23 18:20:34 -070054 return signalType;
55 }
56
57 @Override
58 public int hashCode() {
59 return Objects.hash(number(), isEnabled(), type(), signalType, annotations());
60 }
61
62 @Override
63 public boolean equals(Object obj) {
64 if (this == obj) {
65 return true;
66 }
Satish K7cfdc632015-11-27 19:48:41 +053067 if (obj != null && getClass() == obj.getClass()) {
Marc De Leenheerbb382352015-04-23 18:20:34 -070068 final OduCltPort other = (OduCltPort) obj;
69 return Objects.equals(this.element().id(), other.element().id()) &&
70 Objects.equals(this.number(), other.number()) &&
71 Objects.equals(this.isEnabled(), other.isEnabled()) &&
72 Objects.equals(this.signalType, other.signalType) &&
73 Objects.equals(this.annotations(), other.annotations());
74 }
75 return false;
76 }
77
78
79 @Override
80 public String toString() {
81 return toStringHelper(this)
82 .add("element", element().id())
83 .add("number", number())
84 .add("isEnabled", isEnabled())
85 .add("type", type())
86 .add("signalType", signalType)
87 .toString();
88 }
89
90}