add toString
Change-Id: I2a38b27164c4c4c0e259a32dbb283dd384b61c26
Showing
5 changed files
with
45 additions
and
9 deletions
| 1 | package org.onlab.onos.store.service; | 1 | package org.onlab.onos.store.service; |
| 2 | 2 | ||
| 3 | +import com.google.common.base.MoreObjects; | ||
| 4 | + | ||
| 3 | /** | 5 | /** |
| 4 | * Database read request. | 6 | * Database read request. |
| 5 | */ | 7 | */ |
| ... | @@ -31,6 +33,9 @@ public class ReadRequest { | ... | @@ -31,6 +33,9 @@ public class ReadRequest { |
| 31 | 33 | ||
| 32 | @Override | 34 | @Override |
| 33 | public String toString() { | 35 | public String toString() { |
| 34 | - return "ReadRequest [tableName=" + tableName + ", key=" + key + "]"; | 36 | + return MoreObjects.toStringHelper(getClass()) |
| 37 | + .add("tableName", tableName) | ||
| 38 | + .add("key", key) | ||
| 39 | + .toString(); | ||
| 35 | } | 40 | } |
| 36 | } | 41 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | package org.onlab.onos.store.service; | 1 | package org.onlab.onos.store.service; |
| 2 | 2 | ||
| 3 | +import com.google.common.base.MoreObjects; | ||
| 4 | + | ||
| 3 | 5 | ||
| 4 | /** | 6 | /** |
| 5 | * Database read result. | 7 | * Database read result. |
| ... | @@ -18,7 +20,7 @@ public class ReadResult { | ... | @@ -18,7 +20,7 @@ public class ReadResult { |
| 18 | 20 | ||
| 19 | /** | 21 | /** |
| 20 | * Returns database table name. | 22 | * Returns database table name. |
| 21 | - * @return table name. | 23 | + * @return table name |
| 22 | */ | 24 | */ |
| 23 | public String tableName() { | 25 | public String tableName() { |
| 24 | return tableName; | 26 | return tableName; |
| ... | @@ -26,7 +28,7 @@ public class ReadResult { | ... | @@ -26,7 +28,7 @@ public class ReadResult { |
| 26 | 28 | ||
| 27 | /** | 29 | /** |
| 28 | * Returns database table key. | 30 | * Returns database table key. |
| 29 | - * @return key. | 31 | + * @return key |
| 30 | */ | 32 | */ |
| 31 | public String key() { | 33 | public String key() { |
| 32 | return key; | 34 | return key; |
| ... | @@ -39,4 +41,13 @@ public class ReadResult { | ... | @@ -39,4 +41,13 @@ public class ReadResult { |
| 39 | public VersionedValue value() { | 41 | public VersionedValue value() { |
| 40 | return value; | 42 | return value; |
| 41 | } | 43 | } |
| 44 | + | ||
| 45 | + @Override | ||
| 46 | + public String toString() { | ||
| 47 | + return MoreObjects.toStringHelper(getClass()) | ||
| 48 | + .add("tableName", tableName) | ||
| 49 | + .add("key", key) | ||
| 50 | + .add("value", value) | ||
| 51 | + .toString(); | ||
| 52 | + } | ||
| 42 | } | 53 | } | ... | ... |
| ... | @@ -2,6 +2,8 @@ package org.onlab.onos.store.service; | ... | @@ -2,6 +2,8 @@ package org.onlab.onos.store.service; |
| 2 | 2 | ||
| 3 | import java.util.Arrays; | 3 | import java.util.Arrays; |
| 4 | 4 | ||
| 5 | +import com.google.common.base.MoreObjects; | ||
| 6 | + | ||
| 5 | /** | 7 | /** |
| 6 | * Wrapper object that holds the object (as byte array) and its version. | 8 | * Wrapper object that holds the object (as byte array) and its version. |
| 7 | */ | 9 | */ |
| ... | @@ -38,7 +40,9 @@ public class VersionedValue { | ... | @@ -38,7 +40,9 @@ public class VersionedValue { |
| 38 | 40 | ||
| 39 | @Override | 41 | @Override |
| 40 | public String toString() { | 42 | public String toString() { |
| 41 | - return "VersionedValue [value=" + Arrays.toString(value) + ", version=" | 43 | + return MoreObjects.toStringHelper(getClass()) |
| 42 | - + version + "]"; | 44 | + .add("version", version) |
| 45 | + .add("value", Arrays.toString(value)) | ||
| 46 | + .toString(); | ||
| 43 | } | 47 | } |
| 44 | } | 48 | } | ... | ... |
| ... | @@ -4,6 +4,8 @@ import static com.google.common.base.Preconditions.checkArgument; | ... | @@ -4,6 +4,8 @@ import static com.google.common.base.Preconditions.checkArgument; |
| 4 | 4 | ||
| 5 | import java.util.Objects; | 5 | import java.util.Objects; |
| 6 | 6 | ||
| 7 | +import com.google.common.base.MoreObjects; | ||
| 8 | + | ||
| 7 | /** | 9 | /** |
| 8 | * Database write request. | 10 | * Database write request. |
| 9 | */ | 11 | */ |
| ... | @@ -67,10 +69,13 @@ public class WriteRequest { | ... | @@ -67,10 +69,13 @@ public class WriteRequest { |
| 67 | 69 | ||
| 68 | @Override | 70 | @Override |
| 69 | public String toString() { | 71 | public String toString() { |
| 70 | - return "WriteRequest [tableName=" + tableName + ", key=" + key | 72 | + return MoreObjects.toStringHelper(getClass()) |
| 71 | - + ", newValue=" + newValue | 73 | + .add("tableName", tableName) |
| 72 | - + ", previousVersion=" + previousVersion | 74 | + .add("key", key) |
| 73 | - + ", oldValue=" + oldValue; | 75 | + .add("newValue", newValue) |
| 76 | + .add("previousVersion", previousVersion) | ||
| 77 | + .add("oldValue", oldValue) | ||
| 78 | + .toString(); | ||
| 74 | } | 79 | } |
| 75 | 80 | ||
| 76 | @Override | 81 | @Override | ... | ... |
| 1 | package org.onlab.onos.store.service; | 1 | package org.onlab.onos.store.service; |
| 2 | 2 | ||
| 3 | +import com.google.common.base.MoreObjects; | ||
| 4 | + | ||
| 3 | 5 | ||
| 4 | /** | 6 | /** |
| 5 | * Database write result. | 7 | * Database write result. |
| ... | @@ -27,4 +29,13 @@ public class WriteResult { | ... | @@ -27,4 +29,13 @@ public class WriteResult { |
| 27 | public VersionedValue previousValue() { | 29 | public VersionedValue previousValue() { |
| 28 | return previousValue; | 30 | return previousValue; |
| 29 | } | 31 | } |
| 32 | + | ||
| 33 | + @Override | ||
| 34 | + public String toString() { | ||
| 35 | + return MoreObjects.toStringHelper(getClass()) | ||
| 36 | + .add("tableName", tableName) | ||
| 37 | + .add("key", key) | ||
| 38 | + .add("previousValue", previousValue) | ||
| 39 | + .toString(); | ||
| 40 | + } | ||
| 30 | } | 41 | } | ... | ... |
-
Please register or login to post a comment