Madan Jampani | 346d4f5 | 2015-05-04 11:09:39 -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 | */ |
| 16 | package org.onosproject.store.consistent.impl; |
| 17 | |
| 18 | /** |
| 19 | * Result of a update operation. |
| 20 | * <p> |
| 21 | * Both old and new values are accessible along with a flag that indicates if the |
| 22 | * the value was updated. If flag is false, oldValue and newValue both |
| 23 | * point to the same unmodified value. |
| 24 | * @param <V> result type |
| 25 | */ |
| 26 | public class UpdateResult<V> { |
| 27 | |
| 28 | private final boolean updated; |
| 29 | private final V oldValue; |
| 30 | private final V newValue; |
| 31 | |
| 32 | public UpdateResult(boolean updated, V oldValue, V newValue) { |
| 33 | this.updated = updated; |
| 34 | this.oldValue = oldValue; |
| 35 | this.newValue = newValue; |
| 36 | } |
| 37 | |
| 38 | public boolean updated() { |
| 39 | return updated; |
| 40 | } |
| 41 | |
| 42 | public V oldValue() { |
| 43 | return oldValue; |
| 44 | } |
| 45 | |
| 46 | public V newValue() { |
| 47 | return newValue; |
| 48 | } |
| 49 | } |