blob: 73c4d1271e90e568c594b35494970a00a1785a40 [file] [log] [blame]
Jordan Halterman45008172018-03-19 16:40:31 -07001/*
2 * Copyright 2018-present Open Networking Foundation
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 */
16package org.onosproject.store.primitives.impl;
17
18import org.onosproject.core.Version;
19
20import static com.google.common.base.MoreObjects.toStringHelper;
21
22/**
23 * Compatibility wrapper for primitive values.
24 */
25public class CompatibleValue<T> {
26 private final T value;
27 private final Version version;
28
29 public CompatibleValue(T value, Version version) {
30 this.value = value;
31 this.version = version;
32 }
33
34 /**
35 * Returns the wrapped value.
36 *
37 * @return the wrapped value
38 */
39 public T value() {
40 return value;
41 }
42
43 /**
44 * Returns the compatibilty version.
45 *
46 * @return the compatibility version
47 */
48 public Version version() {
49 return version;
50 }
51
52 @Override
53 public String toString() {
54 return toStringHelper(this)
55 .add("value", value)
56 .add("version", version)
57 .toString();
58 }
59}