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