blob: e936f48d2329e46fcbbf283830bb16eb7ca39d82 [file] [log] [blame]
Madan Jampani08822c42014-11-04 17:17:46 -08001package org.onlab.onos.store.service.impl;
2
3import org.onlab.onos.store.service.WriteResult;
4
Madan Jampani348a9fe2014-11-09 01:37:51 -08005import com.google.common.base.MoreObjects;
6
Madan Jampani686fa182014-11-04 23:16:27 -08007/**
8 * Result of a write operation executed on the DatabaseStateMachine.
9 */
Madan Jampani08822c42014-11-04 17:17:46 -080010public class InternalWriteResult {
11
12 public enum Status {
13 OK,
14 ABORTED,
15 NO_SUCH_TABLE,
Yuta HIGUCHI361664e2014-11-06 17:28:47 -080016 PREVIOUS_VERSION_MISMATCH,
Madan Jampani08822c42014-11-04 17:17:46 -080017 PREVIOUS_VALUE_MISMATCH
18 }
19
20 private final Status status;
21 private final WriteResult result;
22
Yuta HIGUCHI361664e2014-11-06 17:28:47 -080023 public static InternalWriteResult ok(WriteResult result) {
24 return new InternalWriteResult(Status.OK, result);
25 }
26
Madan Jampani08822c42014-11-04 17:17:46 -080027 public InternalWriteResult(Status status, WriteResult result) {
28 this.status = status;
29 this.result = result;
30 }
31
32 public Status status() {
33 return status;
34 }
35
36 public WriteResult result() {
37 return result;
38 }
Madan Jampani348a9fe2014-11-09 01:37:51 -080039
40 @Override
41 public String toString() {
42 return MoreObjects.toStringHelper(getClass())
43 .add("status", status)
44 .add("result", result)
45 .toString();
46 }
Madan Jampani08822c42014-11-04 17:17:46 -080047}