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; |
| 21 | |
| 22 | /** |
| 23 | * Implementation of ODU client port (Optical channel Data Unit). |
| 24 | * Also referred to as a T-port or wide band port. |
| 25 | * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)" |
| 26 | */ |
| 27 | |
| 28 | public class OduCltPort extends DefaultPort { |
| 29 | |
| 30 | public enum SignalType { |
| 31 | CLT_1GBE, |
| 32 | CLT_10GBE, |
| 33 | CLT_40GBE, |
| 34 | CLT_100GBE |
| 35 | } |
| 36 | |
| 37 | private final SignalType signalType; |
| 38 | |
| 39 | |
| 40 | /** |
| 41 | * Creates an ODU client port in the specified network element. |
| 42 | * |
| 43 | * @param element parent network element |
| 44 | * @param number port number |
| 45 | * @param isEnabled port enabled state |
| 46 | * @param signalType ODU client signal type |
| 47 | * @param annotations optional key/value annotations |
| 48 | */ |
| 49 | public OduCltPort(Element element, PortNumber number, boolean isEnabled, |
| 50 | SignalType signalType, Annotations... annotations) { |
| 51 | super(element, number, isEnabled, Type.ODUCLT, 0, annotations); |
| 52 | this.signalType = signalType; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Returns ODU client signal type. |
| 57 | * |
| 58 | * @return ODU client signal type |
| 59 | */ |
| 60 | public SignalType signalType() { |
| 61 | return signalType; |
| 62 | } |
| 63 | |
| 64 | @Override |
| 65 | public int hashCode() { |
| 66 | return Objects.hash(number(), isEnabled(), type(), signalType, annotations()); |
| 67 | } |
| 68 | |
| 69 | @Override |
| 70 | public boolean equals(Object obj) { |
| 71 | if (this == obj) { |
| 72 | return true; |
| 73 | } |
| 74 | if (obj instanceof OduCltPort) { |
| 75 | final OduCltPort other = (OduCltPort) obj; |
| 76 | return Objects.equals(this.element().id(), other.element().id()) && |
| 77 | Objects.equals(this.number(), other.number()) && |
| 78 | Objects.equals(this.isEnabled(), other.isEnabled()) && |
| 79 | Objects.equals(this.signalType, other.signalType) && |
| 80 | Objects.equals(this.annotations(), other.annotations()); |
| 81 | } |
| 82 | return false; |
| 83 | } |
| 84 | |
| 85 | |
| 86 | @Override |
| 87 | public String toString() { |
| 88 | return toStringHelper(this) |
| 89 | .add("element", element().id()) |
| 90 | .add("number", number()) |
| 91 | .add("isEnabled", isEnabled()) |
| 92 | .add("type", type()) |
| 93 | .add("signalType", signalType) |
| 94 | .toString(); |
| 95 | } |
| 96 | |
| 97 | } |