blob: b6398f42c08d3ce4597bb5b1a69f96e475be89f7 [file] [log] [blame]
Marc De Leenheerbb382352015-04-23 18:20:34 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Marc De Leenheerbb382352015-04-23 18:20:34 -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.device;
17
18import com.google.common.base.MoreObjects;
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070019import org.onosproject.net.OchSignal;
20import org.onosproject.net.OduSignalType;
Marc De Leenheerbb382352015-04-23 18:20:34 -070021import org.onosproject.net.Port;
22import org.onosproject.net.PortNumber;
23import org.onosproject.net.SparseAnnotations;
24
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070025import static com.google.common.base.Preconditions.checkNotNull;
26
Marc De Leenheerbb382352015-04-23 18:20:34 -070027/**
28 * Default implementation of immutable OCh port description.
29 */
30public class OchPortDescription extends DefaultPortDescription {
31
Sho SHIMIZU014c33a2015-04-30 11:40:37 -070032 private final OduSignalType signalType;
Marc De Leenheerbb382352015-04-23 18:20:34 -070033 private final boolean isTunable;
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070034 private final OchSignal lambda;
Marc De Leenheerbb382352015-04-23 18:20:34 -070035
36 /**
37 * Creates OCH port description based on the supplied information.
38 *
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070039 * @param number port number
40 * @param isEnabled port enabled state
41 * @param signalType ODU signal type
42 * @param isTunable tunable wavelength capability
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070043 * @param lambda OCh signal
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070044 * @param annotations optional key/value annotations map
Marc De Leenheerbb382352015-04-23 18:20:34 -070045 */
Sho SHIMIZU014c33a2015-04-30 11:40:37 -070046 public OchPortDescription(PortNumber number, boolean isEnabled, OduSignalType signalType,
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070047 boolean isTunable, OchSignal lambda, SparseAnnotations... annotations) {
Marc De Leenheerbb382352015-04-23 18:20:34 -070048 super(number, isEnabled, Port.Type.OCH, 0, annotations);
49 this.signalType = signalType;
50 this.isTunable = isTunable;
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070051 this.lambda = checkNotNull(lambda);
Marc De Leenheerbb382352015-04-23 18:20:34 -070052 }
53
54 /**
55 * Creates OCH port description based on the supplied information.
56 *
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070057 * @param base PortDescription to get basic information from
58 * @param signalType ODU signal type
59 * @param isTunable tunable wavelength capability
60 * @param lambda OCh signal
61 * @param annotations optional key/value annotations map
Marc De Leenheerbb382352015-04-23 18:20:34 -070062 */
Sho SHIMIZU014c33a2015-04-30 11:40:37 -070063 public OchPortDescription(PortDescription base, OduSignalType signalType, boolean isTunable,
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070064 OchSignal lambda, SparseAnnotations annotations) {
Marc De Leenheerbb382352015-04-23 18:20:34 -070065 super(base, annotations);
66 this.signalType = signalType;
67 this.isTunable = isTunable;
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070068 this.lambda = checkNotNull(lambda);
Marc De Leenheerbb382352015-04-23 18:20:34 -070069 }
70
71 /**
72 * Returns ODU signal type.
73 *
74 * @return ODU signal type
75 */
Sho SHIMIZU014c33a2015-04-30 11:40:37 -070076 public OduSignalType signalType() {
Marc De Leenheerbb382352015-04-23 18:20:34 -070077 return signalType;
78 }
79
80 /**
81 * Returns true if port is wavelength tunable.
82 *
83 * @return tunable wavelength capability
84 */
85 public boolean isTunable() {
86 return isTunable;
87 }
88
89 /**
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070090 * Returns OCh signal.
Marc De Leenheerbb382352015-04-23 18:20:34 -070091 *
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070092 * @return OCh signal
Marc De Leenheerbb382352015-04-23 18:20:34 -070093 */
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070094 public OchSignal lambda() {
95 return lambda;
Marc De Leenheerbb382352015-04-23 18:20:34 -070096 }
97
98 @Override
99 public String toString() {
100 return MoreObjects.toStringHelper(getClass())
101 .add("number", portNumber())
102 .add("isEnabled", isEnabled())
103 .add("type", type())
104 .add("signalType", signalType)
105 .add("isTunable", isTunable)
Sho SHIMIZU0abceb82015-05-04 09:20:53 -0700106 .add("lambda", lambda)
Marc De Leenheerbb382352015-04-23 18:20:34 -0700107 .add("annotations", annotations())
108 .toString();
109 }
110
111}