blob: 49e9665403469f718a565d724a98223aee188b50 [file] [log] [blame]
Madan Jampani08822c42014-11-04 17:17:46 -08001package org.onlab.onos.store.service;
2
Yuta HIGUCHI5e1cfe02014-11-04 21:22:45 -08003import com.google.common.base.MoreObjects;
4
Madan Jampani08822c42014-11-04 17:17:46 -08005
6/**
7 * Database read result.
8 */
9public class ReadResult {
10
11 private final String tableName;
12 private final String key;
13 private final VersionedValue value;
14
15 public ReadResult(String tableName, String key, VersionedValue value) {
16 this.tableName = tableName;
17 this.key = key;
18 this.value = value;
19 }
20
21 /**
Madan Jampani9b19a822014-11-04 21:37:13 -080022 * Returns database table name.
Yuta HIGUCHI5e1cfe02014-11-04 21:22:45 -080023 * @return table name
Madan Jampani08822c42014-11-04 17:17:46 -080024 */
25 public String tableName() {
26 return tableName;
27 }
28
29 /**
Madan Jampani9b19a822014-11-04 21:37:13 -080030 * Returns database table key.
Yuta HIGUCHI5e1cfe02014-11-04 21:22:45 -080031 * @return key
Madan Jampani08822c42014-11-04 17:17:46 -080032 */
33 public String key() {
34 return key;
35 }
36
37 /**
Yuta HIGUCHI361664e2014-11-06 17:28:47 -080038 * Returns true if database table contained value for the key.
39 *
40 * @return true if database table contained value for the key
41 */
42 public boolean valueExists() {
43 return value != null;
44 }
45
46 /**
Madan Jampani9b19a822014-11-04 21:37:13 -080047 * Returns value associated with the key.
Madan Jampani08822c42014-11-04 17:17:46 -080048 * @return non-null value if the table contains one, null otherwise.
49 */
50 public VersionedValue value() {
51 return value;
52 }
Yuta HIGUCHI5e1cfe02014-11-04 21:22:45 -080053
54 @Override
55 public String toString() {
56 return MoreObjects.toStringHelper(getClass())
57 .add("tableName", tableName)
58 .add("key", key)
59 .add("value", value)
60 .toString();
61 }
Madan Jampani08822c42014-11-04 17:17:46 -080062}