blob: 8bcf8b4170d1444f38233a4b481db09e83539467 [file] [log] [blame]
Madan Jampani08822c42014-11-04 17:17:46 -08001package org.onlab.onos.store.service;
2
Yuta HIGUCHIcea3ba12014-11-05 18:18:08 -08003import static com.google.common.base.Preconditions.checkNotNull;
4
Yuta HIGUCHI5e1cfe02014-11-04 21:22:45 -08005import com.google.common.base.MoreObjects;
6
Madan Jampani08822c42014-11-04 17:17:46 -08007/**
8 * Database read request.
9 */
10public class ReadRequest {
11
12 private final String tableName;
13 private final String key;
14
Yuta HIGUCHIcea3ba12014-11-05 18:18:08 -080015
16 /**
17 * Creates a read request,
18 * which will retrieve the specified key from the table.
19 *
20 * @param tableName name of the table
21 * @param key key in the table
22 * @return ReadRequest
23 */
24 public static ReadRequest get(String tableName, String key) {
25 return new ReadRequest(tableName, key);
26 }
27
Madan Jampani08822c42014-11-04 17:17:46 -080028 public ReadRequest(String tableName, String key) {
Yuta HIGUCHIcea3ba12014-11-05 18:18:08 -080029 this.tableName = checkNotNull(tableName);
30 this.key = checkNotNull(key);
Madan Jampani08822c42014-11-04 17:17:46 -080031 }
32
33 /**
34 * Return the name of the table.
35 * @return table name.
36 */
37 public String tableName() {
38 return tableName;
39 }
40
41 /**
42 * Returns the key.
43 * @return key.
44 */
45 public String key() {
46 return key;
47 }
48
49 @Override
50 public String toString() {
Yuta HIGUCHI5e1cfe02014-11-04 21:22:45 -080051 return MoreObjects.toStringHelper(getClass())
52 .add("tableName", tableName)
53 .add("key", key)
54 .toString();
Madan Jampani08822c42014-11-04 17:17:46 -080055 }
56}