blob: 60f25158e4f4f12c738bcc02b3aa9a5f47865475 [file] [log] [blame]
Rimon Ashkenazy8ebfff02016-02-01 11:56:36 +02001/*
2 * Copyright 2016 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.device;
17
18import com.google.common.base.MoreObjects;
19
20import org.onosproject.net.OtuSignalType;
21import org.onosproject.net.Port;
22import org.onosproject.net.PortNumber;
23import org.onosproject.net.SparseAnnotations;
24
25/**
26 * Default implementation of immutable OTU port description.
27 */
28public class OtuPortDescription extends DefaultPortDescription {
29
30 private final OtuSignalType signalType;
31
32 /**
33 * Creates OTU port description based on the supplied information.
34 *
35 * @param number port number
36 * @param isEnabled port enabled state
37 * @param signalType OTU signal type
38 * @param annotations optional key/value annotations map
39 */
40 public OtuPortDescription(PortNumber number, boolean isEnabled, OtuSignalType signalType,
41 SparseAnnotations... annotations) {
42 super(number, isEnabled, Port.Type.OTU, 0, annotations);
43 this.signalType = signalType;
44 }
45
46 /**
47 * Creates OTU port description based on the supplied information.
48 *
49 * @param base PortDescription to get basic information from
50 * @param signalType OTU signal type
51 * @param annotations optional key/value annotations map
52 */
53 public OtuPortDescription(PortDescription base, OtuSignalType signalType,
54 SparseAnnotations annotations) {
55 super(base, annotations);
56 this.signalType = signalType;
57 }
58
59 /**
60 * Returns OTU signal type.
61 *
62 * @return OTU signal type
63 */
64 public OtuSignalType signalType() {
65 return signalType;
66 }
67
68 @Override
69 public String toString() {
70 return MoreObjects.toStringHelper(getClass())
71 .add("number", portNumber())
72 .add("isEnabled", isEnabled())
73 .add("type", type())
74 .add("signalType", signalType)
75 .toString();
76 }
77
78}