Madan Jampani | 61056bc | 2014-09-27 09:07:26 -0700 | [diff] [blame^] | 1 | package org.onlab.onos.store.device.impl; |
| 2 | |
| 3 | import org.onlab.onos.store.Timestamp; |
| 4 | |
| 5 | /** |
| 6 | * Wrapper class for a entity that is versioned |
| 7 | * and can either be up or down. |
| 8 | * |
| 9 | * @param <T> type of the value. |
| 10 | */ |
| 11 | public class VersionedValue<T> { |
| 12 | private final T entity; |
| 13 | private final Timestamp timestamp; |
| 14 | private final boolean isUp; |
| 15 | |
| 16 | public VersionedValue(T entity, boolean isUp, Timestamp timestamp) { |
| 17 | this.entity = entity; |
| 18 | this.isUp = isUp; |
| 19 | this.timestamp = timestamp; |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * Returns the value. |
| 24 | * @return value. |
| 25 | */ |
| 26 | public T entity() { |
| 27 | return entity; |
| 28 | } |
| 29 | |
| 30 | /** |
| 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 | } |
| 37 | |
| 38 | /** |
| 39 | * Returns the timestamp (version) associated with this entity. |
| 40 | * @return timestamp. |
| 41 | */ |
| 42 | public Timestamp timestamp() { |
| 43 | return timestamp; |
| 44 | } |
| 45 | } |