1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package com.linecorp.centraldogma.client.updater;
17
18 import static com.linecorp.centraldogma.internal.Util.validateFilePath;
19
20 import java.util.Objects;
21 import java.util.Optional;
22
23 import javax.annotation.Nullable;
24
25 import com.google.common.base.MoreObjects;
26 import com.google.common.base.Strings;
27
28
29
30
31
32
33
34 public final class CentralDogmaBeanConfig {
35
36 static final CentralDogmaBeanConfig EMPTY = new CentralDogmaBeanConfigBuilder().build();
37
38 private final String project;
39 private final String repository;
40 private final String path;
41 private final String jsonPath;
42
43
44
45
46
47
48
49
50
51 public CentralDogmaBeanConfig(@Nullable String project, @Nullable String repository,
52 @Nullable String path, @Nullable String jsonPath) {
53
54 this.project = Strings.emptyToNull(project);
55 this.repository = Strings.emptyToNull(repository);
56 this.path = Strings.emptyToNull(path);
57 this.jsonPath = Strings.emptyToNull(jsonPath);
58
59 if (this.path != null) {
60 validateFilePath(this.path, "path");
61 }
62 }
63
64
65
66
67
68
69 public Optional<String> project() {
70 return Optional.ofNullable(project);
71 }
72
73
74
75
76
77
78 public Optional<String> repository() {
79 return Optional.ofNullable(repository);
80 }
81
82
83
84
85
86
87 public Optional<String> path() {
88 return Optional.ofNullable(path);
89 }
90
91
92
93
94
95
96 public Optional<String> jsonPath() {
97 return Optional.ofNullable(jsonPath);
98 }
99
100 @Override
101 public boolean equals(Object o) {
102 if (o == this) {
103 return true;
104 }
105 if (!(o instanceof CentralDogmaBeanConfig)) {
106 return false;
107 }
108 final CentralDogmaBeanConfig other = (CentralDogmaBeanConfig) o;
109 return Objects.equals(project, other.project) &&
110 Objects.equals(repository, other.repository) &&
111 Objects.equals(path, other.path) &&
112 Objects.equals(jsonPath, other.jsonPath);
113 }
114
115 @Override
116 public int hashCode() {
117 return Objects.hash(project, repository, path, jsonPath);
118 }
119
120 @Override
121 public String toString() {
122 return MoreObjects.toStringHelper(this).omitNullValues()
123 .add("project", project)
124 .add("repository", repository)
125 .add("path", path)
126 .add("jsonPath", jsonPath)
127 .toString();
128 }
129 }