HIGUCHI Yuta | 5be3e82 | 2016-05-03 13:51:42 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present 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.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.OtuPortHelper.stripHandledAnnotations; |
HIGUCHI Yuta | 5be3e82 | 2016-05-03 13:51:42 -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 | 5be3e82 | 2016-05-03 13:51:42 -0700 | [diff] [blame] | 24 | import org.onosproject.net.OtuSignalType; |
| 25 | import org.onosproject.net.Port; |
| 26 | import org.onosproject.net.optical.OtuPort; |
HIGUCHI Yuta | f46dc4f | 2016-05-13 11:24:13 -0700 | [diff] [blame] | 27 | import org.onosproject.net.utils.ForwardingPort; |
HIGUCHI Yuta | 5be3e82 | 2016-05-03 13:51:42 -0700 | [diff] [blame] | 28 | |
| 29 | import com.google.common.annotations.Beta; |
| 30 | |
| 31 | /** |
| 32 | * Implementation of OTU port (Optical channel Transport Unit). |
| 33 | * |
| 34 | */ |
| 35 | @Beta |
| 36 | public class DefaultOtuPort extends ForwardingPort implements OtuPort { |
| 37 | |
| 38 | private final OtuSignalType signalType; |
| 39 | |
| 40 | /** |
| 41 | * Creates an ODU client port. |
| 42 | * |
| 43 | * @param delegate Port |
| 44 | * @param signalType OTU signal type |
| 45 | */ |
| 46 | public DefaultOtuPort(Port delegate, OtuSignalType signalType) { |
| 47 | super(delegate); |
| 48 | this.signalType = checkNotNull(signalType); |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public Type type() { |
| 53 | return Type.OTU; |
| 54 | } |
| 55 | |
| 56 | // @Override |
| 57 | // public long portSpeed() { |
| 58 | // return signalType().bitRate(); |
| 59 | // } |
| 60 | |
| 61 | @Override |
Yuta HIGUCHI | 1d547bf | 2016-08-02 21:44:48 -0700 | [diff] [blame] | 62 | public Annotations unhandledAnnotations() { |
| 63 | return stripHandledAnnotations(super.annotations()); |
| 64 | } |
| 65 | |
| 66 | @Override |
HIGUCHI Yuta | 5be3e82 | 2016-05-03 13:51:42 -0700 | [diff] [blame] | 67 | public OtuSignalType signalType() { |
| 68 | return signalType; |
| 69 | } |
| 70 | |
| 71 | @Override |
| 72 | public int hashCode() { |
| 73 | return Objects.hash(super.hashCode(), |
| 74 | signalType()); |
| 75 | } |
| 76 | |
| 77 | @Override |
| 78 | public boolean equals(Object obj) { |
| 79 | if (this == obj) { |
| 80 | return true; |
| 81 | } |
| 82 | |
| 83 | if (obj != null && getClass() == obj.getClass()) { |
| 84 | final DefaultOtuPort that = (DefaultOtuPort) obj; |
| 85 | return super.toEqualsBuilder(that) |
| 86 | .append(this.signalType(), that.signalType()) |
| 87 | .isEquals(); |
| 88 | } |
| 89 | return false; |
| 90 | } |
| 91 | |
| 92 | @Override |
| 93 | public String toString() { |
| 94 | return super.toStringHelper() |
| 95 | .add("signalType", signalType()) |
Yuta HIGUCHI | 1d547bf | 2016-08-02 21:44:48 -0700 | [diff] [blame] | 96 | .add("annotations", unhandledAnnotations()) |
HIGUCHI Yuta | 5be3e82 | 2016-05-03 13:51:42 -0700 | [diff] [blame] | 97 | .toString(); |
| 98 | } |
| 99 | |
| 100 | } |