blob: 1a85c53acde62741d9a689f4c73e9fc4b879a5e1 [file] [log] [blame]
Madan Jampani61056bc2014-09-27 09:07:26 -07001package org.onlab.onos.store.device.impl;
2
3import org.onlab.onos.store.Timestamp;
4
5/**
Yuta HIGUCHI2e963892014-09-27 13:00:39 -07006 * Wrapper class for a entity that is versioned
Madan Jampani61056bc2014-09-27 09:07:26 -07007 * and can either be up or down.
8 *
9 * @param <T> type of the value.
10 */
11public class VersionedValue<T> {
12 private final T entity;
13 private final Timestamp timestamp;
14 private final boolean isUp;
Yuta HIGUCHI2e963892014-09-27 13:00:39 -070015
Madan Jampani61056bc2014-09-27 09:07:26 -070016 public VersionedValue(T entity, boolean isUp, Timestamp timestamp) {
17 this.entity = entity;
18 this.isUp = isUp;
19 this.timestamp = timestamp;
20 }
Yuta HIGUCHI2e963892014-09-27 13:00:39 -070021
Madan Jampani61056bc2014-09-27 09:07:26 -070022 /**
23 * Returns the value.
24 * @return value.
25 */
26 public T entity() {
27 return entity;
28 }
Yuta HIGUCHI2e963892014-09-27 13:00:39 -070029
Madan Jampani61056bc2014-09-27 09:07:26 -070030 /**
31 * Tells whether the entity is up or down.
32 * @return true if up, false otherwise.
33 */
34 public boolean isUp() {
35 return isUp;
36 }
Yuta HIGUCHI2e963892014-09-27 13:00:39 -070037
Madan Jampani61056bc2014-09-27 09:07:26 -070038 /**
39 * Returns the timestamp (version) associated with this entity.
40 * @return timestamp.
41 */
42 public Timestamp timestamp() {
43 return timestamp;
44 }
45}