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 | |
| 18 | import java.util.Objects; |
| 19 | |
| 20 | import static com.google.common.base.MoreObjects.toStringHelper; |
Toru Furusawa | 0f5da69 | 2016-01-07 14:51:47 -0800 | [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 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 | |
| 29 | public class OduCltPort extends DefaultPort { |
| 30 | |
Toru Furusawa | 72ee30c | 2016-01-08 13:29:04 -0800 | [diff] [blame] | 31 | private final CltSignalType signalType; |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 32 | |
| 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 Furusawa | 72ee30c | 2016-01-08 13:29:04 -0800 | [diff] [blame] | 43 | CltSignalType signalType, Annotations... annotations) { |
| 44 | super(element, number, isEnabled, Type.ODUCLT, checkNotNull(signalType).bitRate(), annotations); |
| 45 | this.signalType = signalType; |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Returns ODU client signal type. |
| 50 | * |
| 51 | * @return ODU client signal type |
| 52 | */ |
Toru Furusawa | 72ee30c | 2016-01-08 13:29:04 -0800 | [diff] [blame] | 53 | public CltSignalType signalType() { |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 54 | 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 K | 7cfdc63 | 2015-11-27 19:48:41 +0530 | [diff] [blame] | 67 | if (obj != null && getClass() == obj.getClass()) { |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 68 | 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 | } |