lishuai | 2ddc469 | 2015-07-31 15:15:16 +0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
lishuai | 2ddc469 | 2015-07-31 15:15:16 +0800 | [diff] [blame] | 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.OvsdbTable; |
| 21 | import org.onosproject.ovsdb.rfc.table.VersionNum; |
| 22 | import org.onosproject.ovsdb.rfc.utils.VersionUtil; |
| 23 | |
| 24 | /** |
| 25 | * Table description. |
| 26 | */ |
| 27 | public class TableDescription { |
| 28 | |
| 29 | // The table name |
| 30 | private final String name; |
| 31 | // The database name |
nitinanand | 9e8f836 | 2018-05-31 15:11:04 +0530 | [diff] [blame^] | 32 | private final String database; |
lishuai | 2ddc469 | 2015-07-31 15:15:16 +0800 | [diff] [blame] | 33 | // The initial version |
| 34 | private final String fromVersion; |
| 35 | // The end of the version |
| 36 | private final String untilVersion; |
| 37 | |
| 38 | /** |
| 39 | * Constructs a MonitorRequest object. |
| 40 | * @param table OvsdbTable entity |
| 41 | */ |
| 42 | public TableDescription(OvsdbTable table) { |
| 43 | checkNotNull(table, "table cannot be null"); |
| 44 | this.name = table.tableName(); |
| 45 | this.fromVersion = VersionUtil.DEFAULT_VERSION_STRING; |
| 46 | this.untilVersion = VersionUtil.DEFAULT_VERSION_STRING; |
nitinanand | 9e8f836 | 2018-05-31 15:11:04 +0530 | [diff] [blame^] | 47 | this.database = "Open_vSwitch"; |
lishuai | 2ddc469 | 2015-07-31 15:15:16 +0800 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Constructs a MonitorRequest object. |
| 52 | * @param table OvsdbTable entity |
| 53 | * @param fromVersion the initial version |
| 54 | */ |
| 55 | public TableDescription(OvsdbTable table, VersionNum fromVersion) { |
| 56 | checkNotNull(table, "table cannot be null"); |
| 57 | checkNotNull(fromVersion, "the initial version cannot be null"); |
| 58 | this.name = table.tableName(); |
| 59 | this.fromVersion = fromVersion.versionNum(); |
| 60 | this.untilVersion = VersionUtil.DEFAULT_VERSION_STRING; |
nitinanand | 9e8f836 | 2018-05-31 15:11:04 +0530 | [diff] [blame^] | 61 | this.database = "Open_vSwitch"; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Constructs a MonitorRequest object. |
| 66 | * @param table OvsdbTable entity |
| 67 | * @param database database name |
| 68 | * @param fromVersion the initial version |
| 69 | * @param untilVersion the untill version |
| 70 | */ |
| 71 | public TableDescription(OvsdbTable table, String database, VersionNum fromVersion, VersionNum untilVersion) { |
| 72 | checkNotNull(table, "table cannot be null"); |
| 73 | checkNotNull(database, "database cannot be null"); |
| 74 | checkNotNull(fromVersion, "the initial version cannot be null"); |
| 75 | checkNotNull(untilVersion, "the end of the version cannot be null"); |
| 76 | this.name = table.tableName(); |
| 77 | this.fromVersion = fromVersion.versionNum(); |
| 78 | this.untilVersion = untilVersion.versionNum(); |
| 79 | this.database = database; |
lishuai | 2ddc469 | 2015-07-31 15:15:16 +0800 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Constructs a MonitorRequest object. |
| 84 | * @param table OvsdbTable entity |
| 85 | * @param fromVersion the initial version |
| 86 | * @param untilVersion the end of the version |
| 87 | */ |
| 88 | public TableDescription(OvsdbTable table, VersionNum fromVersion, VersionNum untilVersion) { |
| 89 | checkNotNull(table, "table cannot be null"); |
| 90 | checkNotNull(fromVersion, "the initial version cannot be null"); |
| 91 | checkNotNull(untilVersion, "the end of the version cannot be null"); |
| 92 | this.name = table.tableName(); |
| 93 | this.fromVersion = fromVersion.versionNum(); |
| 94 | this.untilVersion = untilVersion.versionNum(); |
nitinanand | 9e8f836 | 2018-05-31 15:11:04 +0530 | [diff] [blame^] | 95 | this.database = "Open_vSwitch"; |
lishuai | 2ddc469 | 2015-07-31 15:15:16 +0800 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Returns the column name. |
| 100 | * @return the column name |
| 101 | */ |
| 102 | public String name() { |
| 103 | return name; |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * Returns the database name. |
| 108 | * @return the database name |
| 109 | */ |
| 110 | public String database() { |
| 111 | return database; |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Returns the initial version. |
| 116 | * @return the initial version |
| 117 | */ |
| 118 | public String fromVersion() { |
| 119 | return fromVersion; |
| 120 | } |
| 121 | |
| 122 | /** |
| 123 | * Returns the end of the version. |
| 124 | * @return the end of the version |
| 125 | */ |
| 126 | public String untilVersion() { |
| 127 | return untilVersion; |
| 128 | } |
| 129 | } |