blob: 063afc5fdf84724f6c2da7f81dd2d99bebb55bdc [file] [log] [blame]
alshabibab984662014-12-04 18:56:18 -08001/*
2 * Copyright 2014 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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.store.service;
Madan Jampani08822c42014-11-04 17:17:46 -080017
Yuta HIGUCHI5e1cfe02014-11-04 21:22:45 -080018import com.google.common.base.MoreObjects;
19
Madan Jampani08822c42014-11-04 17:17:46 -080020
21/**
22 * Database write result.
23 */
24public class WriteResult {
Madan Jampani23af4fc2014-11-12 00:54:18 -080025
Madan Jampani12390c12014-11-12 00:35:56 -080026 private final WriteStatus status;
Madan Jampani08822c42014-11-04 17:17:46 -080027 private final VersionedValue previousValue;
Madan Jampani23af4fc2014-11-12 00:54:18 -080028
Madan Jampani12390c12014-11-12 00:35:56 -080029 public WriteResult(WriteStatus status, VersionedValue previousValue) {
Madan Jampani23af4fc2014-11-12 00:54:18 -080030 this.status = status;
Madan Jampani08822c42014-11-04 17:17:46 -080031 this.previousValue = previousValue;
32 }
33
Madan Jampani08822c42014-11-04 17:17:46 -080034 public VersionedValue previousValue() {
35 return previousValue;
36 }
Madan Jampani23af4fc2014-11-12 00:54:18 -080037
Madan Jampani12390c12014-11-12 00:35:56 -080038 public WriteStatus status() {
Madan Jampani23af4fc2014-11-12 00:54:18 -080039 return status;
Madan Jampani12390c12014-11-12 00:35:56 -080040 }
Yuta HIGUCHI5e1cfe02014-11-04 21:22:45 -080041
42 @Override
43 public String toString() {
44 return MoreObjects.toStringHelper(getClass())
Madan Jampani23af4fc2014-11-12 00:54:18 -080045 .add("status", status)
Yuta HIGUCHI5e1cfe02014-11-04 21:22:45 -080046 .add("previousValue", previousValue)
47 .toString();
48 }
Madan Jampani08822c42014-11-04 17:17:46 -080049}