Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 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 | */ |
| 16 | package org.onosproject.net; |
| 17 | |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 18 | import java.util.Objects; |
| 19 | |
| 20 | import static com.google.common.base.MoreObjects.toStringHelper; |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 21 | import static com.google.common.base.Preconditions.checkNotNull; |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 22 | |
| 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 Yuta | 34a3f69 | 2016-01-09 21:08:57 -0800 | [diff] [blame] | 27 | * |
| 28 | * @deprecated in Goldeneye (1.6.0) |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 29 | */ |
HIGUCHI Yuta | 34a3f69 | 2016-01-09 21:08:57 -0800 | [diff] [blame] | 30 | @Deprecated |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 31 | public class OchPort extends DefaultPort { |
| 32 | |
Sho SHIMIZU | 014c33a | 2015-04-30 11:40:37 -0700 | [diff] [blame] | 33 | private final OduSignalType signalType; |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 34 | private final boolean isTunable; |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 35 | private final OchSignal lambda; |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 36 | |
| 37 | /** |
| 38 | * Creates an OCh port in the specified network element. |
| 39 | * |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 40 | * @param element parent network element |
| 41 | * @param number port number |
| 42 | * @param isEnabled port enabled state |
| 43 | * @param signalType ODU signal type |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 44 | * @param isTunable tunable wavelength capability |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 45 | * @param lambda OCh signal |
| 46 | * @param annotations optional key/value annotations |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 47 | */ |
Sho SHIMIZU | 014c33a | 2015-04-30 11:40:37 -0700 | [diff] [blame] | 48 | public OchPort(Element element, PortNumber number, boolean isEnabled, OduSignalType signalType, |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 49 | boolean isTunable, OchSignal lambda, Annotations... annotations) { |
Toru Furusawa | 72ee30c | 2016-01-08 13:29:04 -0800 | [diff] [blame] | 50 | super(element, number, isEnabled, Type.OCH, checkNotNull(signalType).bitRate(), annotations); |
| 51 | this.signalType = signalType; |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 52 | this.isTunable = isTunable; |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 53 | this.lambda = checkNotNull(lambda); |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Returns ODU signal type. |
| 58 | * |
| 59 | * @return ODU signal type |
| 60 | */ |
Sho SHIMIZU | 014c33a | 2015-04-30 11:40:37 -0700 | [diff] [blame] | 61 | public OduSignalType signalType() { |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 62 | 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 SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 75 | * Returns OCh signal. |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 76 | * |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 77 | * @return OCh signal |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 78 | */ |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 79 | public OchSignal lambda() { |
| 80 | return lambda; |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | @Override |
| 84 | public int hashCode() { |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 85 | return Objects.hash(number(), isEnabled(), type(), signalType, isTunable, lambda, annotations()); |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | @Override |
| 89 | public boolean equals(Object obj) { |
| 90 | if (this == obj) { |
| 91 | return true; |
| 92 | } |
Satish K | 7cfdc63 | 2015-11-27 19:48:41 +0530 | [diff] [blame] | 93 | |
| 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 Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 96 | 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 SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 102 | Objects.equals(this.lambda, other.lambda) && |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 103 | 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 SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 117 | .add("lambda", lambda) |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 118 | .toString(); |
| 119 | } |
| 120 | } |