Madan Jampani | d352010 | 2015-08-14 11:06:03 -0700 | [diff] [blame] | 1 | /* |
| 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 Jampani | f4c8850 | 2016-01-21 12:35:36 -0800 | [diff] [blame] | 16 | package org.onosproject.store.primitives.impl; |
Madan Jampani | bab51a4 | 2015-08-10 13:53:35 -0700 | [diff] [blame] | 17 | |
| 18 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 19 | |
| 20 | import java.util.Collections; |
| 21 | import java.util.List; |
| 22 | |
| 23 | import com.google.common.collect.ImmutableList; |
| 24 | |
| 25 | /** |
| 26 | * Result of a Transaction commit operation. |
| 27 | */ |
| 28 | public 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 | } |