Madan Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 1 | package org.onlab.onos.store.service; |
| 2 | |
Yuta HIGUCHI | cea3ba1 | 2014-11-05 18:18:08 -0800 | [diff] [blame^] | 3 | import static com.google.common.base.Preconditions.checkNotNull; |
| 4 | |
Yuta HIGUCHI | 5e1cfe0 | 2014-11-04 21:22:45 -0800 | [diff] [blame] | 5 | import com.google.common.base.MoreObjects; |
| 6 | |
Madan Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 7 | /** |
| 8 | * Database read request. |
| 9 | */ |
| 10 | public class ReadRequest { |
| 11 | |
| 12 | private final String tableName; |
| 13 | private final String key; |
| 14 | |
Yuta HIGUCHI | cea3ba1 | 2014-11-05 18:18:08 -0800 | [diff] [blame^] | 15 | |
| 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 Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 28 | public ReadRequest(String tableName, String key) { |
Yuta HIGUCHI | cea3ba1 | 2014-11-05 18:18:08 -0800 | [diff] [blame^] | 29 | this.tableName = checkNotNull(tableName); |
| 30 | this.key = checkNotNull(key); |
Madan Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 31 | } |
| 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 HIGUCHI | 5e1cfe0 | 2014-11-04 21:22:45 -0800 | [diff] [blame] | 51 | return MoreObjects.toStringHelper(getClass()) |
| 52 | .add("tableName", tableName) |
| 53 | .add("key", key) |
| 54 | .toString(); |
Madan Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 55 | } |
| 56 | } |