1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.linecorp.centraldogma.server.command;
18
19 import static java.util.Objects.requireNonNull;
20
21 import java.util.Arrays;
22
23 import javax.annotation.Nullable;
24
25 import com.fasterxml.jackson.annotation.JsonCreator;
26 import com.fasterxml.jackson.annotation.JsonInclude;
27 import com.fasterxml.jackson.annotation.JsonInclude.Include;
28 import com.fasterxml.jackson.annotation.JsonProperty;
29 import com.google.common.base.MoreObjects.ToStringHelper;
30
31 import com.linecorp.centraldogma.common.Author;
32
33
34
35
36 @JsonInclude(Include.NON_NULL)
37 public final class CreateRepositoryCommand extends ProjectCommand<Void> {
38
39 private final String repositoryName;
40 @Nullable
41 private final byte[] wdek;
42
43 @JsonCreator
44 CreateRepositoryCommand(@JsonProperty("timestamp") @Nullable Long timestamp,
45 @JsonProperty("author") @Nullable Author author,
46 @JsonProperty("projectName") String projectName,
47 @JsonProperty("repositoryName") String repositoryName,
48 @JsonProperty("wdek") @Nullable byte[] wdek) {
49 super(CommandType.CREATE_REPOSITORY, timestamp, author, projectName);
50 this.repositoryName = requireNonNull(repositoryName, "repositoryName");
51 this.wdek = wdek != null ? wdek.clone() : null;
52 }
53
54
55
56
57 @JsonProperty
58 public String repositoryName() {
59 return repositoryName;
60 }
61
62
63
64
65 @JsonProperty
66 @Nullable
67 public byte[] wdek() {
68 return wdek != null ? wdek.clone() : null;
69 }
70
71 @Override
72 public boolean equals(Object obj) {
73 if (this == obj) {
74 return true;
75 }
76
77 if (!(obj instanceof CreateRepositoryCommand)) {
78 return false;
79 }
80
81 final CreateRepositoryCommand that = (CreateRepositoryCommand) obj;
82 return super.equals(obj) &&
83 repositoryName.equals(that.repositoryName) &&
84 Arrays.equals(wdek, that.wdek);
85 }
86
87 @Override
88 public int hashCode() {
89 return (repositoryName.hashCode() * 31 + Arrays.hashCode(wdek)) * 31 + super.hashCode();
90 }
91
92 @Override
93 ToStringHelper toStringHelper() {
94 final ToStringHelper toStringHelper = super.toStringHelper()
95 .add("repositoryName", repositoryName);
96 if (wdek != null) {
97 toStringHelper.add("wdek", "[***]");
98 }
99 return toStringHelper;
100 }
101 }