blob: 1b544e692102c187b2f45a72d82aac4ef9438860 [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
Marc De Leenheerbb382352015-04-23 18:20:34 -070018import java.util.Objects;
19
20import static com.google.common.base.MoreObjects.toStringHelper;
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070021import static com.google.common.base.Preconditions.checkNotNull;
Marc De Leenheerbb382352015-04-23 18:20:34 -070022
23/**
24 * Implementation of OCh port (Optical Channel).
25 * Also referred to as a line side port (L-port) or narrow band port.
26 * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
HIGUCHI Yuta34a3f692016-01-09 21:08:57 -080027 *
28 * @deprecated in Goldeneye (1.6.0)
Marc De Leenheerbb382352015-04-23 18:20:34 -070029 */
HIGUCHI Yuta34a3f692016-01-09 21:08:57 -080030@Deprecated
Marc De Leenheerbb382352015-04-23 18:20:34 -070031public class OchPort extends DefaultPort {
32
Sho SHIMIZU014c33a2015-04-30 11:40:37 -070033 private final OduSignalType signalType;
Marc De Leenheerbb382352015-04-23 18:20:34 -070034 private final boolean isTunable;
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070035 private final OchSignal lambda;
Marc De Leenheerbb382352015-04-23 18:20:34 -070036
37 /**
38 * Creates an OCh port in the specified network element.
39 *
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070040 * @param element parent network element
41 * @param number port number
42 * @param isEnabled port enabled state
43 * @param signalType ODU signal type
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070044 * @param isTunable tunable wavelength capability
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070045 * @param lambda OCh signal
46 * @param annotations optional key/value annotations
Marc De Leenheerbb382352015-04-23 18:20:34 -070047 */
Sho SHIMIZU014c33a2015-04-30 11:40:37 -070048 public OchPort(Element element, PortNumber number, boolean isEnabled, OduSignalType signalType,
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070049 boolean isTunable, OchSignal lambda, Annotations... annotations) {
Toru Furusawa72ee30c2016-01-08 13:29:04 -080050 super(element, number, isEnabled, Type.OCH, checkNotNull(signalType).bitRate(), annotations);
51 this.signalType = signalType;
Marc De Leenheerbb382352015-04-23 18:20:34 -070052 this.isTunable = isTunable;
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070053 this.lambda = checkNotNull(lambda);
Marc De Leenheerbb382352015-04-23 18:20:34 -070054 }
55
56 /**
57 * Returns ODU signal type.
58 *
59 * @return ODU signal type
60 */
Sho SHIMIZU014c33a2015-04-30 11:40:37 -070061 public OduSignalType signalType() {
Marc De Leenheerbb382352015-04-23 18:20:34 -070062 return signalType;
63 }
64
65 /**
66 * Returns true if port is wavelength tunable.
67 *
68 * @return tunable wavelength capability
69 */
70 public boolean isTunable() {
71 return isTunable;
72 }
73
74 /**
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070075 * Returns OCh signal.
Marc De Leenheerbb382352015-04-23 18:20:34 -070076 *
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070077 * @return OCh signal
Marc De Leenheerbb382352015-04-23 18:20:34 -070078 */
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070079 public OchSignal lambda() {
80 return lambda;
Marc De Leenheerbb382352015-04-23 18:20:34 -070081 }
82
83 @Override
84 public int hashCode() {
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070085 return Objects.hash(number(), isEnabled(), type(), signalType, isTunable, lambda, annotations());
Marc De Leenheerbb382352015-04-23 18:20:34 -070086 }
87
88 @Override
89 public boolean equals(Object obj) {
90 if (this == obj) {
91 return true;
92 }
Satish K7cfdc632015-11-27 19:48:41 +053093
94 // Subclass is considered as a change of identity, hence equals() will return false if class type don't match
95 if (obj != null && getClass() == obj.getClass()) {
Marc De Leenheerbb382352015-04-23 18:20:34 -070096 final OchPort other = (OchPort) obj;
97 return Objects.equals(this.element().id(), other.element().id()) &&
98 Objects.equals(this.number(), other.number()) &&
99 Objects.equals(this.isEnabled(), other.isEnabled()) &&
100 Objects.equals(this.signalType, other.signalType) &&
101 Objects.equals(this.isTunable, other.isTunable) &&
Sho SHIMIZU0abceb82015-05-04 09:20:53 -0700102 Objects.equals(this.lambda, other.lambda) &&
Marc De Leenheerbb382352015-04-23 18:20:34 -0700103 Objects.equals(this.annotations(), other.annotations());
104 }
105 return false;
106 }
107
108 @Override
109 public String toString() {
110 return toStringHelper(this)
111 .add("element", element().id())
112 .add("number", number())
113 .add("isEnabled", isEnabled())
114 .add("type", type())
115 .add("signalType", signalType)
116 .add("isTunable", isTunable)
Sho SHIMIZU0abceb82015-05-04 09:20:53 -0700117 .add("lambda", lambda)
Marc De Leenheerbb382352015-04-23 18:20:34 -0700118 .toString();
119 }
120}