Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 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 | */ |
| 16 | package org.onosproject.net.device; |
| 17 | |
| 18 | import com.google.common.base.MoreObjects; |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 19 | import org.onosproject.net.OchSignal; |
| 20 | import org.onosproject.net.OduSignalType; |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 21 | import org.onosproject.net.Port; |
| 22 | import org.onosproject.net.PortNumber; |
| 23 | import org.onosproject.net.SparseAnnotations; |
| 24 | |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 25 | import static com.google.common.base.Preconditions.checkNotNull; |
| 26 | |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 27 | /** |
| 28 | * Default implementation of immutable OCh port description. |
| 29 | */ |
| 30 | public class OchPortDescription extends DefaultPortDescription { |
| 31 | |
Sho SHIMIZU | 014c33a | 2015-04-30 11:40:37 -0700 | [diff] [blame] | 32 | private final OduSignalType signalType; |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 33 | private final boolean isTunable; |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 34 | private final OchSignal lambda; |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 35 | |
| 36 | /** |
| 37 | * Creates OCH port description based on the supplied information. |
| 38 | * |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 39 | * @param number port number |
| 40 | * @param isEnabled port enabled state |
| 41 | * @param signalType ODU signal type |
| 42 | * @param isTunable tunable wavelength capability |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 43 | * @param lambda OCh signal |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 44 | * @param annotations optional key/value annotations map |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 45 | */ |
Sho SHIMIZU | 014c33a | 2015-04-30 11:40:37 -0700 | [diff] [blame] | 46 | public OchPortDescription(PortNumber number, boolean isEnabled, OduSignalType signalType, |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 47 | boolean isTunable, OchSignal lambda, SparseAnnotations... annotations) { |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 48 | super(number, isEnabled, Port.Type.OCH, 0, annotations); |
| 49 | this.signalType = signalType; |
| 50 | this.isTunable = isTunable; |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 51 | this.lambda = checkNotNull(lambda); |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Creates OCH port description based on the supplied information. |
| 56 | * |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 57 | * @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 Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 62 | */ |
Sho SHIMIZU | 014c33a | 2015-04-30 11:40:37 -0700 | [diff] [blame] | 63 | public OchPortDescription(PortDescription base, OduSignalType signalType, boolean isTunable, |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 64 | OchSignal lambda, SparseAnnotations annotations) { |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 65 | super(base, annotations); |
| 66 | this.signalType = signalType; |
| 67 | this.isTunable = isTunable; |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 68 | this.lambda = checkNotNull(lambda); |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Returns ODU signal type. |
| 73 | * |
| 74 | * @return ODU signal type |
| 75 | */ |
Sho SHIMIZU | 014c33a | 2015-04-30 11:40:37 -0700 | [diff] [blame] | 76 | public OduSignalType signalType() { |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 77 | 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 SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 90 | * Returns OCh signal. |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 91 | * |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 92 | * @return OCh signal |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 93 | */ |
Sho SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 94 | public OchSignal lambda() { |
| 95 | return lambda; |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 96 | } |
| 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 SHIMIZU | 0abceb8 | 2015-05-04 09:20:53 -0700 | [diff] [blame] | 106 | .add("lambda", lambda) |
Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 107 | .add("annotations", annotations()) |
| 108 | .toString(); |
| 109 | } |
| 110 | |
| 111 | } |