blob: 13d58356e2d4fae8e035380a066c46f962c56e68 [file] [log] [blame]
HIGUCHI Yuta5be3e822016-05-03 13:51:42 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
HIGUCHI Yuta5be3e822016-05-03 13:51:42 -07003 *
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 */
16package org.onosproject.net.optical.impl;
17
18import static com.google.common.base.Preconditions.checkNotNull;
Yuta HIGUCHI1d547bf2016-08-02 21:44:48 -070019import static org.onosproject.net.optical.device.OtuPortHelper.stripHandledAnnotations;
HIGUCHI Yuta5be3e822016-05-03 13:51:42 -070020
21import java.util.Objects;
22
Yuta HIGUCHI1d547bf2016-08-02 21:44:48 -070023import org.onosproject.net.Annotations;
HIGUCHI Yuta5be3e822016-05-03 13:51:42 -070024import org.onosproject.net.OtuSignalType;
25import org.onosproject.net.Port;
26import org.onosproject.net.optical.OtuPort;
HIGUCHI Yutaf46dc4f2016-05-13 11:24:13 -070027import org.onosproject.net.utils.ForwardingPort;
HIGUCHI Yuta5be3e822016-05-03 13:51:42 -070028
29import com.google.common.annotations.Beta;
30
31/**
32 * Implementation of OTU port (Optical channel Transport Unit).
33 *
34 */
35@Beta
36public 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 HIGUCHI1d547bf2016-08-02 21:44:48 -070062 public Annotations unhandledAnnotations() {
63 return stripHandledAnnotations(super.annotations());
64 }
65
66 @Override
HIGUCHI Yuta5be3e822016-05-03 13:51:42 -070067 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 HIGUCHI1d547bf2016-08-02 21:44:48 -070096 .add("annotations", unhandledAnnotations())
HIGUCHI Yuta5be3e822016-05-03 13:51:42 -070097 .toString();
98 }
99
100}