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