HIGUCHI Yuta | 4c0ef6b | 2016-05-02 19:45:41 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
HIGUCHI Yuta | 4c0ef6b | 2016-05-02 19:45:41 -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.optical.impl; |
| 17 | |
| 18 | import static com.google.common.base.Preconditions.checkNotNull; |
Yuta HIGUCHI | 1d547bf | 2016-08-02 21:44:48 -0700 | [diff] [blame] | 19 | import static org.onosproject.net.optical.device.OduCltPortHelper.stripHandledAnnotations; |
HIGUCHI Yuta | 4c0ef6b | 2016-05-02 19:45:41 -0700 | [diff] [blame] | 20 | |
| 21 | import java.util.Objects; |
| 22 | |
Yuta HIGUCHI | 1d547bf | 2016-08-02 21:44:48 -0700 | [diff] [blame] | 23 | import org.onosproject.net.Annotations; |
HIGUCHI Yuta | 4c0ef6b | 2016-05-02 19:45:41 -0700 | [diff] [blame] | 24 | import org.onosproject.net.CltSignalType; |
| 25 | import org.onosproject.net.Port; |
| 26 | import org.onosproject.net.optical.OduCltPort; |
HIGUCHI Yuta | f46dc4f | 2016-05-13 11:24:13 -0700 | [diff] [blame] | 27 | import org.onosproject.net.utils.ForwardingPort; |
HIGUCHI Yuta | 4c0ef6b | 2016-05-02 19:45:41 -0700 | [diff] [blame] | 28 | |
| 29 | import com.google.common.annotations.Beta; |
| 30 | |
| 31 | /** |
| 32 | * Implementation of ODU client port (Optical channel Data Unit). |
| 33 | * Also referred to as a T-port or wide band port. |
| 34 | * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)" |
| 35 | */ |
| 36 | @Beta |
| 37 | public class DefaultOduCltPort extends ForwardingPort implements OduCltPort { |
| 38 | |
| 39 | private final CltSignalType signalType; |
| 40 | |
| 41 | /** |
| 42 | * Creates an ODU client port. |
| 43 | * |
| 44 | * @param delegate Port |
| 45 | * @param signalType ODU client signal type |
| 46 | */ |
| 47 | public DefaultOduCltPort(Port delegate, CltSignalType signalType) { |
| 48 | super(delegate); |
| 49 | this.signalType = checkNotNull(signalType); |
| 50 | } |
| 51 | |
| 52 | @Override |
| 53 | public Type type() { |
| 54 | return Type.ODUCLT; |
| 55 | } |
| 56 | |
| 57 | @Override |
| 58 | public long portSpeed() { |
| 59 | return signalType().bitRate(); |
| 60 | } |
| 61 | |
| 62 | @Override |
Yuta HIGUCHI | 1d547bf | 2016-08-02 21:44:48 -0700 | [diff] [blame] | 63 | public Annotations unhandledAnnotations() { |
| 64 | return stripHandledAnnotations(super.annotations()); |
| 65 | } |
| 66 | |
| 67 | @Override |
HIGUCHI Yuta | 4c0ef6b | 2016-05-02 19:45:41 -0700 | [diff] [blame] | 68 | public CltSignalType signalType() { |
| 69 | return signalType; |
| 70 | } |
| 71 | |
| 72 | @Override |
| 73 | public int hashCode() { |
| 74 | return Objects.hash(super.hashCode(), |
| 75 | signalType()); |
| 76 | } |
| 77 | |
| 78 | @Override |
| 79 | public boolean equals(Object obj) { |
| 80 | if (this == obj) { |
| 81 | return true; |
| 82 | } |
| 83 | |
| 84 | if (obj != null && getClass() == obj.getClass()) { |
| 85 | final DefaultOduCltPort that = (DefaultOduCltPort) obj; |
| 86 | return super.toEqualsBuilder(that) |
| 87 | .append(this.signalType(), that.signalType()) |
| 88 | .isEquals(); |
| 89 | } |
| 90 | return false; |
| 91 | } |
| 92 | |
| 93 | @Override |
| 94 | public String toString() { |
| 95 | return super.toStringHelper() |
| 96 | .add("signalType", signalType()) |
Yuta HIGUCHI | 1d547bf | 2016-08-02 21:44:48 -0700 | [diff] [blame] | 97 | .add("annotations", unhandledAnnotations()) |
HIGUCHI Yuta | 4c0ef6b | 2016-05-02 19:45:41 -0700 | [diff] [blame] | 98 | .toString(); |
| 99 | } |
| 100 | |
| 101 | } |