blob: c835aebb465decc4f302e0f301a94e8fcca8d91c [file] [log] [blame]
lishuai2ddc4692015-07-31 15:15:16 +08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
lishuai2ddc4692015-07-31 15:15:16 +08003 *
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 */
16package org.onosproject.ovsdb.rfc.tableservice;
17
18import static com.google.common.base.Preconditions.checkNotNull;
19
20import org.onosproject.ovsdb.rfc.table.OvsdbTable;
21import org.onosproject.ovsdb.rfc.table.VersionNum;
22import org.onosproject.ovsdb.rfc.utils.VersionUtil;
23
24/**
25 * Table description.
26 */
27public class TableDescription {
28
29 // The table name
30 private final String name;
31 // The database name
nitinanand9e8f8362018-05-31 15:11:04 +053032 private final String database;
lishuai2ddc4692015-07-31 15:15:16 +080033 // 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;
nitinanand9e8f8362018-05-31 15:11:04 +053047 this.database = "Open_vSwitch";
lishuai2ddc4692015-07-31 15:15:16 +080048 }
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;
nitinanand9e8f8362018-05-31 15:11:04 +053061 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;
lishuai2ddc4692015-07-31 15:15:16 +080080 }
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();
nitinanand9e8f8362018-05-31 15:11:04 +053095 this.database = "Open_vSwitch";
lishuai2ddc4692015-07-31 15:15:16 +080096 }
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}