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.onlab.util.Frequency; |
| 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 OMS port description. |
| 26 | */ |
| 27 | public class OmsPortDescription extends DefaultPortDescription { |
| 28 | |
| 29 | private final Frequency minFrequency; |
| 30 | private final Frequency maxFrequency; |
| 31 | private final Frequency grid; |
| 32 | |
| 33 | /** |
| 34 | * Creates OMS port description based on the supplied information. |
| 35 | * |
| 36 | * @param number port number |
| 37 | * @param isEnabled port enabled state |
| 38 | * @param minFrequency minimum frequency |
| 39 | * @param maxFrequency maximum frequency |
| 40 | * @param grid grid spacing frequency |
| 41 | * @param annotations optional key/value annotations map |
| 42 | */ |
| 43 | public OmsPortDescription(PortNumber number, boolean isEnabled, Frequency minFrequency, Frequency maxFrequency, |
| 44 | Frequency grid, SparseAnnotations... annotations) { |
| 45 | super(number, isEnabled, Port.Type.OMS, 0, annotations); |
| 46 | this.minFrequency = minFrequency; |
| 47 | this.maxFrequency = maxFrequency; |
| 48 | this.grid = grid; |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Creates OMS port description based on the supplied information. |
| 53 | * |
| 54 | * @param base PortDescription to get basic information from |
| 55 | * @param minFrequency minimum frequency |
| 56 | * @param maxFrequency maximum frequency |
| 57 | * @param grid grid spacing frequency |
| 58 | * @param annotations optional key/value annotations map |
| 59 | */ |
| 60 | public OmsPortDescription(PortDescription base, Frequency minFrequency, Frequency maxFrequency, |
| 61 | Frequency grid, SparseAnnotations annotations) { |
| 62 | super(base, annotations); |
| 63 | this.minFrequency = minFrequency; |
| 64 | this.maxFrequency = maxFrequency; |
| 65 | this.grid = grid; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Returns minimum frequency. |
| 70 | * |
| 71 | * @return minimum frequency |
| 72 | */ |
| 73 | public Frequency minFrequency() { |
| 74 | return minFrequency; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Returns maximum frequency. |
| 79 | * |
| 80 | * @return maximum frequency |
| 81 | */ |
| 82 | public Frequency maxFrequency() { |
| 83 | return maxFrequency; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Returns grid spacing frequency. |
| 88 | * |
| 89 | * @return grid spacing frequency |
| 90 | */ |
| 91 | public Frequency grid() { |
| 92 | return grid; |
| 93 | } |
| 94 | |
| 95 | @Override |
| 96 | public String toString() { |
| 97 | return MoreObjects.toStringHelper(getClass()) |
| 98 | .add("number", portNumber()) |
| 99 | .add("isEnabled", isEnabled()) |
| 100 | .add("type", type()) |
| 101 | .add("minFrequency", minFrequency) |
| 102 | .add("maxFrequency", maxFrequency) |
| 103 | .add("grid", grid) |
| 104 | .add("annotations", annotations()) |
| 105 | .toString(); |
| 106 | } |
| 107 | |
| 108 | } |
| 109 | |