blob: 78a4266463864a65b86fc7e8875a91de35f65ac9 [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;
19
20import java.util.Objects;
21
22import org.onosproject.net.CltSignalType;
23import org.onosproject.net.Port;
24import org.onosproject.net.optical.OduCltPort;
HIGUCHI Yutaf46dc4f2016-05-13 11:24:13 -070025import org.onosproject.net.utils.ForwardingPort;
HIGUCHI Yuta4c0ef6b2016-05-02 19:45:41 -070026
27import com.google.common.annotations.Beta;
28
29/**
30 * Implementation of ODU client port (Optical channel Data Unit).
31 * Also referred to as a T-port or wide band port.
32 * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
33 */
34@Beta
35public class DefaultOduCltPort extends ForwardingPort implements OduCltPort {
36
37 private final CltSignalType signalType;
38
39 /**
40 * Creates an ODU client port.
41 *
42 * @param delegate Port
43 * @param signalType ODU client signal type
44 */
45 public DefaultOduCltPort(Port delegate, CltSignalType signalType) {
46 super(delegate);
47 this.signalType = checkNotNull(signalType);
48 }
49
50 @Override
51 public Type type() {
52 return Type.ODUCLT;
53 }
54
55 @Override
56 public long portSpeed() {
57 return signalType().bitRate();
58 }
59
60 @Override
61 public CltSignalType signalType() {
62 return signalType;
63 }
64
65 @Override
66 public int hashCode() {
67 return Objects.hash(super.hashCode(),
68 signalType());
69 }
70
71 @Override
72 public boolean equals(Object obj) {
73 if (this == obj) {
74 return true;
75 }
76
77 if (obj != null && getClass() == obj.getClass()) {
78 final DefaultOduCltPort that = (DefaultOduCltPort) obj;
79 return super.toEqualsBuilder(that)
80 .append(this.signalType(), that.signalType())
81 .isEquals();
82 }
83 return false;
84 }
85
86 @Override
87 public String toString() {
88 return super.toStringHelper()
89 .add("signalType", signalType())
90 .toString();
91 }
92
93}