blob: ee306896a645a3a20f6972b67ca04a7d55133c10 [file] [log] [blame]
Madan Jampani25461112015-02-17 14:17:29 -08001/*
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
Madan Jampani393e0f02015-02-12 07:35:39 +053017package org.onosproject.store.service;
Madan Jampani94c23532015-02-05 17:40:01 -080018
19import com.google.common.base.MoreObjects;
20
21/**
22 * Versioned value.
23 *
24 * @param <V> value type.
25 */
26public class Versioned<V> {
27
28 private final V value;
29 private final long version;
30
31 /**
32 * Constructs a new versioned value.
33 * @param value value
34 * @param version version
35 */
36 public Versioned(V value, long version) {
37 this.value = value;
38 this.version = version;
39 }
40
41 /**
42 * Returns the value.
43 *
44 * @return value.
45 */
46 public V value() {
47 return value;
48 }
49
50 /**
51 * Returns the version.
52 *
53 * @return version
54 */
55 public long version() {
56 return version;
57 }
58
59 @Override
60 public String toString() {
61 return MoreObjects.toStringHelper(this)
62 .add("value", value)
63 .add("version", version)
64 .toString();
65 }
66}