Showing
1 changed file
with
0 additions
and
79 deletions
| 1 | -package org.onlab.onos.store.link.impl; | ||
| 2 | - | ||
| 3 | -import java.util.Objects; | ||
| 4 | - | ||
| 5 | -import org.onlab.onos.store.Timestamp; | ||
| 6 | - | ||
| 7 | -// TODO: remove once we stop using this | ||
| 8 | -/** | ||
| 9 | - * Wrapper class for a entity that is versioned | ||
| 10 | - * and can either be up or down. | ||
| 11 | - * | ||
| 12 | - * @param <T> type of the value. | ||
| 13 | - */ | ||
| 14 | -public class VersionedValue<T> { | ||
| 15 | - private final T entity; | ||
| 16 | - private final Timestamp timestamp; | ||
| 17 | - private final boolean isUp; | ||
| 18 | - | ||
| 19 | - public VersionedValue(T entity, boolean isUp, Timestamp timestamp) { | ||
| 20 | - this.entity = entity; | ||
| 21 | - this.isUp = isUp; | ||
| 22 | - this.timestamp = timestamp; | ||
| 23 | - } | ||
| 24 | - | ||
| 25 | - /** | ||
| 26 | - * Returns the value. | ||
| 27 | - * @return value. | ||
| 28 | - */ | ||
| 29 | - public T entity() { | ||
| 30 | - return entity; | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | - /** | ||
| 34 | - * Tells whether the entity is up or down. | ||
| 35 | - * @return true if up, false otherwise. | ||
| 36 | - */ | ||
| 37 | - public boolean isUp() { | ||
| 38 | - return isUp; | ||
| 39 | - } | ||
| 40 | - | ||
| 41 | - /** | ||
| 42 | - * Returns the timestamp (version) associated with this entity. | ||
| 43 | - * @return timestamp. | ||
| 44 | - */ | ||
| 45 | - public Timestamp timestamp() { | ||
| 46 | - return timestamp; | ||
| 47 | - } | ||
| 48 | - | ||
| 49 | - | ||
| 50 | - @Override | ||
| 51 | - public int hashCode() { | ||
| 52 | - return Objects.hash(entity, timestamp, isUp); | ||
| 53 | - } | ||
| 54 | - | ||
| 55 | - @Override | ||
| 56 | - public boolean equals(Object obj) { | ||
| 57 | - if (this == obj) { | ||
| 58 | - return true; | ||
| 59 | - } | ||
| 60 | - if (obj == null) { | ||
| 61 | - return false; | ||
| 62 | - } | ||
| 63 | - if (getClass() != obj.getClass()) { | ||
| 64 | - return false; | ||
| 65 | - } | ||
| 66 | - @SuppressWarnings("unchecked") | ||
| 67 | - VersionedValue<T> that = (VersionedValue<T>) obj; | ||
| 68 | - return Objects.equals(this.entity, that.entity) && | ||
| 69 | - Objects.equals(this.timestamp, that.timestamp) && | ||
| 70 | - Objects.equals(this.isUp, that.isUp); | ||
| 71 | - } | ||
| 72 | - | ||
| 73 | - // Default constructor for serializer | ||
| 74 | - protected VersionedValue() { | ||
| 75 | - this.entity = null; | ||
| 76 | - this.isUp = false; | ||
| 77 | - this.timestamp = null; | ||
| 78 | - } | ||
| 79 | -} |
-
Please register or login to post a comment