blob: 4e1848bdf4d2ae511eed3685340b37c91a24ed6d [file] [log] [blame]
Madan Jampani12390c12014-11-12 00:35:56 -08001package org.onlab.onos.store.service;
2
3import java.util.Collections;
4import java.util.List;
5
Madan Jampani23af4fc2014-11-12 00:54:18 -08006/**
7 * Result of a batch write operation.
8 */
Madan Jampani12390c12014-11-12 00:35:56 -08009public class BatchWriteResult {
Madan Jampani23af4fc2014-11-12 00:54:18 -080010
11 private final List<WriteResult> writeResults;
12
13 public BatchWriteResult(List<WriteResult> writeResults) {
14 this.writeResults = Collections.unmodifiableList(writeResults);
15 }
16
17 /**
18 * Returns true if this batch write operation was successful.
19 * @return true if successful, false otherwise.
20 */
21 public boolean isSuccessful() {
22 for (WriteResult result : writeResults) {
23 if (result.status() != WriteStatus.OK) {
24 return false;
25 }
26 }
27 return true;
28 }
29
30 /**
31 * Returns the results as a List.
32 * @return list of batch results.
33 */
34 public List<WriteResult> getAsList() {
35 return this.writeResults;
36 }
37
38 /**
39 * Returns the size of this batch.
40 * @return batch size.
41 */
42 public int batchSize() {
43 return writeResults.size();
44 }
45}