lishuai | 2ddc469 | 2015-07-31 15:15:16 +0800 | [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.ovsdb.rfc.tableservice; |
| 17 | |
| 18 | import static com.google.common.base.Preconditions.checkNotNull; |
| 19 | |
| 20 | import org.onosproject.ovsdb.rfc.table.VersionNum; |
| 21 | import org.onosproject.ovsdb.rfc.utils.VersionUtil; |
| 22 | |
| 23 | /** |
| 24 | * Column description. |
| 25 | */ |
| 26 | public class ColumnDescription { |
| 27 | |
| 28 | // The column name |
| 29 | private final String name; |
| 30 | // The method name |
| 31 | private final String method; |
| 32 | // The initial version |
| 33 | private final String fromVersion; |
| 34 | // The end of the version |
| 35 | private final String untilVersion; |
| 36 | |
| 37 | /** |
| 38 | * Constructs a MonitorRequest object. |
| 39 | * @param name column name |
| 40 | * @param method method name |
| 41 | */ |
| 42 | public ColumnDescription(String name, String method) { |
| 43 | checkNotNull(name, "name cannot be null"); |
| 44 | checkNotNull(method, "method cannot be null"); |
| 45 | this.name = name; |
| 46 | this.method = method; |
| 47 | this.fromVersion = VersionUtil.DEFAULT_VERSION_STRING; |
| 48 | this.untilVersion = VersionUtil.DEFAULT_VERSION_STRING; |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Constructs a MonitorRequest object. |
| 53 | * @param name column name |
| 54 | * @param method method name |
| 55 | * @param fromVersion the initial version |
| 56 | */ |
| 57 | public ColumnDescription(String name, String method, VersionNum fromVersion) { |
| 58 | checkNotNull(name, "name cannot be null"); |
| 59 | checkNotNull(method, "method cannot be null"); |
| 60 | checkNotNull(fromVersion, "the initial version cannot be null"); |
| 61 | this.name = name; |
| 62 | this.method = method; |
| 63 | this.fromVersion = fromVersion.versionNum(); |
| 64 | this.untilVersion = VersionUtil.DEFAULT_VERSION_STRING; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Constructs a MonitorRequest object. |
| 69 | * @param name column name |
| 70 | * @param method method name |
| 71 | * @param fromVersion the initial version |
| 72 | * @param untilVersion the end of the version |
| 73 | */ |
| 74 | public ColumnDescription(String name, String method, VersionNum fromVersion, |
| 75 | VersionNum untilVersion) { |
| 76 | checkNotNull(name, "name cannot be null"); |
| 77 | checkNotNull(method, "method cannot be null"); |
| 78 | checkNotNull(fromVersion, "the initial version cannot be null"); |
| 79 | checkNotNull(untilVersion, "the end of the version cannot be null"); |
| 80 | this.name = name; |
| 81 | this.method = method; |
| 82 | this.fromVersion = fromVersion.versionNum(); |
| 83 | this.untilVersion = untilVersion.versionNum(); |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Returns the column name. |
| 88 | * @return the column name |
| 89 | */ |
| 90 | public String name() { |
| 91 | return name; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Returns the method name. |
| 96 | * @return the method name |
| 97 | */ |
| 98 | public String method() { |
| 99 | return method; |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Returns the initial version. |
| 104 | * @return the initial version |
| 105 | */ |
| 106 | public String fromVersion() { |
| 107 | return fromVersion; |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * Returns the end of the version. |
| 112 | * @return the end of the version |
| 113 | */ |
| 114 | public String untilVersion() { |
| 115 | return untilVersion; |
| 116 | } |
| 117 | } |