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