1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.linecorp.centraldogma.client;
18
19 import static java.util.Objects.requireNonNull;
20
21 import java.util.Objects;
22
23 import javax.annotation.Nullable;
24
25 import com.google.common.base.MoreObjects;
26
27 import com.linecorp.centraldogma.common.Revision;
28
29
30
31
32
33
34 public final class Latest<U> {
35
36 private final Revision revision;
37 @Nullable
38 private final U value;
39
40
41
42
43 public Latest(Revision revision, @Nullable U value) {
44 this.revision = requireNonNull(revision, "revision");
45 this.value = value;
46 }
47
48
49
50
51 public Revision revision() {
52 return revision;
53 }
54
55
56
57
58 @Nullable
59 public U value() {
60 return value;
61 }
62
63 @Override
64 public boolean equals(Object o) {
65 if (this == o) {
66 return true;
67 }
68 if (!(o instanceof Latest<?>)) {
69 return false;
70 }
71 final Latest<?> that = (Latest<?>) o;
72 return revision.equals(that.revision) && Objects.equals(value, that.value);
73 }
74
75 @Override
76 public int hashCode() {
77 return revision.hashCode() * 31 + Objects.hashCode(value);
78 }
79
80 @Override
81 public String toString() {
82 return MoreObjects.toStringHelper(this)
83 .add("revision", revision)
84 .add("value", value)
85 .toString();
86 }
87 }