blob: b185072277f5716a77e184650a3bdf4eca1e9503 [file] [log] [blame]
Madan Jampani12390c12014-11-12 00:35:56 -08001package org.onlab.onos.store.service;
2
Madan Jampani12390c12014-11-12 00:35:56 -08003import java.util.List;
4
Madan Jampani7aad2332014-11-12 01:57:07 -08005import com.google.common.collect.ImmutableList;
6
Madan Jampani23af4fc2014-11-12 00:54:18 -08007/**
8 * Result of a batch write operation.
9 */
Madan Jampani12390c12014-11-12 00:35:56 -080010public class BatchWriteResult {
Madan Jampani23af4fc2014-11-12 00:54:18 -080011
12 private final List<WriteResult> writeResults;
13
14 public BatchWriteResult(List<WriteResult> writeResults) {
Madan Jampani7aad2332014-11-12 01:57:07 -080015 this.writeResults = ImmutableList.copyOf(writeResults);
Madan Jampani23af4fc2014-11-12 00:54:18 -080016 }
17
18 /**
19 * Returns true if this batch write operation was successful.
20 * @return true if successful, false otherwise.
21 */
22 public boolean isSuccessful() {
23 for (WriteResult result : writeResults) {
24 if (result.status() != WriteStatus.OK) {
25 return false;
26 }
27 }
28 return true;
29 }
30
31 /**
32 * Returns the results as a List.
33 * @return list of batch results.
34 */
35 public List<WriteResult> getAsList() {
36 return this.writeResults;
37 }
38
39 /**
40 * Returns the size of this batch.
41 * @return batch size.
42 */
43 public int batchSize() {
44 return writeResults.size();
45 }
46}