sangyun-han
Committed by Gerrit Code Review

Add javadoc for MapValue

Change-Id: I025e21a670562e387138afddcdd78a214b3a81e1
...@@ -34,6 +34,7 @@ public class MapValue<V> implements Comparable<MapValue<V>> { ...@@ -34,6 +34,7 @@ public class MapValue<V> implements Comparable<MapValue<V>> {
34 34
35 /** 35 /**
36 * Creates a tombstone value with the specified timestamp. 36 * Creates a tombstone value with the specified timestamp.
37 + *
37 * @param timestamp timestamp for tombstone 38 * @param timestamp timestamp for tombstone
38 * @return tombstone MapValue 39 * @return tombstone MapValue
39 * 40 *
...@@ -43,12 +44,18 @@ public class MapValue<V> implements Comparable<MapValue<V>> { ...@@ -43,12 +44,18 @@ public class MapValue<V> implements Comparable<MapValue<V>> {
43 return new MapValue<>(null, timestamp, System.currentTimeMillis()); 44 return new MapValue<>(null, timestamp, System.currentTimeMillis());
44 } 45 }
45 46
47 + /**
48 + * Constructor automatically to create the system time of construction.
49 + *
50 + * @param value value
51 + * @param timestamp value timestamp
52 + */
46 public MapValue(V value, Timestamp timestamp) { 53 public MapValue(V value, Timestamp timestamp) {
47 this(value, timestamp, System.currentTimeMillis()); 54 this(value, timestamp, System.currentTimeMillis());
48 } 55 }
49 56
50 /** 57 /**
51 - * Constructor. 58 + * Creates a map value using value, timestamp, and creation time.
52 * 59 *
53 * @param value value 60 * @param value value
54 * @param timestamp value timestamp. 61 * @param timestamp value timestamp.
...@@ -71,31 +78,57 @@ public class MapValue<V> implements Comparable<MapValue<V>> { ...@@ -71,31 +78,57 @@ public class MapValue<V> implements Comparable<MapValue<V>> {
71 return new MapValue<>(this.value, this.timestamp, System.currentTimeMillis()); 78 return new MapValue<>(this.value, this.timestamp, System.currentTimeMillis());
72 } 79 }
73 80
81 + /**
82 + * Tests if this value is tombstone value with the specified timestamp.
83 + *
84 + * @return true if this value is null, otherwise false
85 + */
74 public boolean isTombstone() { 86 public boolean isTombstone() {
75 return value == null; 87 return value == null;
76 } 88 }
77 89
90 + /**
91 + * Tests if this value is alive.
92 + *
93 + * @return true if this value is not null, otherwise false
94 + */
78 public boolean isAlive() { 95 public boolean isAlive() {
79 return value != null; 96 return value != null;
80 } 97 }
81 98
99 + /**
100 + * Returns the timestamp of this value.
101 + *
102 + * @return timestamp
103 + */
82 public Timestamp timestamp() { 104 public Timestamp timestamp() {
83 return timestamp; 105 return timestamp;
84 } 106 }
85 107
108 + /**
109 + * Returns this value.
110 + *
111 + * @return value
112 + */
86 public V get() { 113 public V get() {
87 return value; 114 return value;
88 } 115 }
89 116
117 + /**
118 + * Returns the creation time of this value.
119 + *
120 + * @return creationTime
121 + */
90 public long creationTime() { 122 public long creationTime() {
91 return creationTime; 123 return creationTime;
92 } 124 }
93 125
94 - @Override 126 + /**
95 - public int compareTo(MapValue<V> o) { 127 + * Tests if this value is newer than the specified MapValue.
96 - return this.timestamp.compareTo(o.timestamp); 128 + *
97 - } 129 + * @param other the value to be compared
98 - 130 + * @return true if this value is newer than other
131 + */
99 public boolean isNewerThan(MapValue<V> other) { 132 public boolean isNewerThan(MapValue<V> other) {
100 if (other == null) { 133 if (other == null) {
101 return true; 134 return true;
...@@ -103,15 +136,31 @@ public class MapValue<V> implements Comparable<MapValue<V>> { ...@@ -103,15 +136,31 @@ public class MapValue<V> implements Comparable<MapValue<V>> {
103 return this.timestamp.isNewerThan(other.timestamp); 136 return this.timestamp.isNewerThan(other.timestamp);
104 } 137 }
105 138
139 + /**
140 + * Tests if this timestamp is newer than the specified timestamp.
141 + *
142 + * @param timestamp timestamp to be compared
143 + * @return true if this instance is newer
144 + */
106 public boolean isNewerThan(Timestamp timestamp) { 145 public boolean isNewerThan(Timestamp timestamp) {
107 return this.timestamp.isNewerThan(timestamp); 146 return this.timestamp.isNewerThan(timestamp);
108 } 147 }
109 148
149 + /**
150 + * Returns summary of a MapValue for use during Anti-Entropy exchanges.
151 + *
152 + * @return Digest with timestamp and whether this value is null or not
153 + */
110 public Digest digest() { 154 public Digest digest() {
111 return new Digest(timestamp, isTombstone()); 155 return new Digest(timestamp, isTombstone());
112 } 156 }
113 157
114 @Override 158 @Override
159 + public int compareTo(MapValue<V> o) {
160 + return this.timestamp.compareTo(o.timestamp);
161 + }
162 +
163 + @Override
115 public int hashCode() { 164 public int hashCode() {
116 return Objects.hashCode(timestamp, value); 165 return Objects.hashCode(timestamp, value);
117 } 166 }
......