Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 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)" |
| 27 | */ |
| 28 | public class OchPort extends DefaultPort { |
| 29 | |
Sho SHIMIZU | 014c33a | 2015-04-30 11:40:37 -0700 | [diff] [blame] | 30 | private final OduSignalType signalType; |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 31 | private final boolean isTunable; |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 32 | private final OchSignal lambda; |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 33 | |
| 34 | /** |
| 35 | * Creates an OCh port in the specified network element. |
| 36 | * |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 37 | * @param element parent network element |
| 38 | * @param number port number |
| 39 | * @param isEnabled port enabled state |
| 40 | * @param signalType ODU signal type |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 41 | * @param isTunable tunable wavelength capability |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 42 | * @param lambda OCh signal |
| 43 | * @param annotations optional key/value annotations |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 44 | */ |
Sho SHIMIZU | 014c33a | 2015-04-30 11:40:37 -0700 | [diff] [blame] | 45 | public OchPort(Element element, PortNumber number, boolean isEnabled, OduSignalType signalType, |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 46 | boolean isTunable, OchSignal lambda, Annotations... annotations) { |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 47 | super(element, number, isEnabled, Type.OCH, 0, annotations); |
| 48 | this.signalType = signalType; |
| 49 | this.isTunable = isTunable; |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 50 | this.lambda = checkNotNull(lambda); |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Returns ODU signal type. |
| 55 | * |
| 56 | * @return ODU signal type |
| 57 | */ |
Sho SHIMIZU | 014c33a | 2015-04-30 11:40:37 -0700 | [diff] [blame] | 58 | public OduSignalType signalType() { |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 59 | return signalType; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Returns true if port is wavelength tunable. |
| 64 | * |
| 65 | * @return tunable wavelength capability |
| 66 | */ |
| 67 | public boolean isTunable() { |
| 68 | return isTunable; |
| 69 | } |
| 70 | |
| 71 | /** |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 72 | * Returns OCh signal. |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 73 | * |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 74 | * @return OCh signal |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 75 | */ |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 76 | public OchSignal lambda() { |
| 77 | return lambda; |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | @Override |
| 81 | public int hashCode() { |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 82 | return Objects.hash(number(), isEnabled(), type(), signalType, isTunable, lambda, annotations()); |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | @Override |
| 86 | public boolean equals(Object obj) { |
| 87 | if (this == obj) { |
| 88 | return true; |
| 89 | } |
| 90 | if (obj instanceof OchPort) { |
| 91 | final OchPort other = (OchPort) obj; |
| 92 | return Objects.equals(this.element().id(), other.element().id()) && |
| 93 | Objects.equals(this.number(), other.number()) && |
| 94 | Objects.equals(this.isEnabled(), other.isEnabled()) && |
| 95 | Objects.equals(this.signalType, other.signalType) && |
| 96 | Objects.equals(this.isTunable, other.isTunable) && |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 97 | Objects.equals(this.lambda, other.lambda) && |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 98 | Objects.equals(this.annotations(), other.annotations()); |
| 99 | } |
| 100 | return false; |
| 101 | } |
| 102 | |
| 103 | @Override |
| 104 | public String toString() { |
| 105 | return toStringHelper(this) |
| 106 | .add("element", element().id()) |
| 107 | .add("number", number()) |
| 108 | .add("isEnabled", isEnabled()) |
| 109 | .add("type", type()) |
| 110 | .add("signalType", signalType) |
| 111 | .add("isTunable", isTunable) |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 112 | .add("lambda", lambda) |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 113 | .toString(); |
| 114 | } |
| 115 | } |