blob: adb6b2742a1602f9686fad333fcb19b52f6cb522 [file] [log] [blame]
HIGUCHI Yuta4c0ef6b2016-05-02 19:45:41 -07001/*
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 */
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.OduCltPortHelper.stripHandledAnnotations;
HIGUCHI Yuta4c0ef6b2016-05-02 19:45:41 -070020
21import java.util.Objects;
22
Yuta HIGUCHI1d547bf2016-08-02 21:44:48 -070023import org.onosproject.net.Annotations;
HIGUCHI Yuta4c0ef6b2016-05-02 19:45:41 -070024import org.onosproject.net.CltSignalType;
25import org.onosproject.net.Port;
26import org.onosproject.net.optical.OduCltPort;
HIGUCHI Yutaf46dc4f2016-05-13 11:24:13 -070027import org.onosproject.net.utils.ForwardingPort;
HIGUCHI Yuta4c0ef6b2016-05-02 19:45:41 -070028
29import 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
37public 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 HIGUCHI1d547bf2016-08-02 21:44:48 -070063 public Annotations unhandledAnnotations() {
64 return stripHandledAnnotations(super.annotations());
65 }
66
67 @Override
HIGUCHI Yuta4c0ef6b2016-05-02 19:45:41 -070068 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 HIGUCHI1d547bf2016-08-02 21:44:48 -070097 .add("annotations", unhandledAnnotations())
HIGUCHI Yuta4c0ef6b2016-05-02 19:45:41 -070098 .toString();
99 }
100
101}