blob: a18ade48964d12292ab93cb8795bd158871bfe06 [file] [log] [blame]
Madan Jampanid3520102015-08-14 11:06:03 -07001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Madan Jampanif4c88502016-01-21 12:35:36 -080016package org.onosproject.store.primitives.impl;
Madan Jampanibab51a42015-08-10 13:53:35 -070017
18import static com.google.common.base.MoreObjects.toStringHelper;
19
20import java.util.Collections;
21import java.util.List;
22
23import com.google.common.collect.ImmutableList;
24
25/**
26 * Result of a Transaction commit operation.
27 */
28public final class CommitResponse {
29
30 private boolean success;
31 private List<UpdateResult<String, byte[]>> updates;
32
33 public static CommitResponse success(List<UpdateResult<String, byte[]>> updates) {
34 return new CommitResponse(true, updates);
35 }
36
37 public static CommitResponse failure() {
38 return new CommitResponse(false, Collections.emptyList());
39 }
40
41 private CommitResponse(boolean success, List<UpdateResult<String, byte[]>> updates) {
42 this.success = success;
43 this.updates = ImmutableList.copyOf(updates);
44 }
45
46 public boolean success() {
47 return success;
48 }
49
50 public List<UpdateResult<String, byte[]>> updates() {
51 return updates;
52 }
53
54 @Override
55 public String toString() {
56 return toStringHelper(this)
57 .add("success", success)
58 .add("udpates", updates)
59 .toString();
60 }
61}