1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.linecorp.centraldogma.internal.api.v1;
18
19 import static com.linecorp.centraldogma.internal.api.v1.HttpApiV1Constants.CONTENTS;
20 import static com.linecorp.centraldogma.internal.api.v1.HttpApiV1Constants.PROJECTS_PREFIX;
21 import static com.linecorp.centraldogma.internal.api.v1.HttpApiV1Constants.REPOS;
22 import static java.util.Objects.requireNonNull;
23
24 import org.jspecify.annotations.Nullable;
25
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;
30
31 import com.linecorp.centraldogma.common.EntryType;
32 import com.linecorp.centraldogma.common.Revision;
33
34 @JsonInclude(Include.NON_NULL)
35 public class EntryDto<T> {
36
37 private final Revision revision;
38 @Nullable
39 private final Revision templateRevision;
40
41 private final String path;
42
43
44
45
46
47
48
49 @Deprecated
50 private final EntryType type;
51
52 @Nullable
53 private final T content;
54 @Nullable
55 private final String rawContent;
56
57 private final String url;
58
59 public EntryDto(Revision revision, String path, EntryType type,
60 String projectName, String repoName, @Nullable T content, @Nullable String rawContent,
61 @Nullable Revision templateRevision) {
62 this.revision = requireNonNull(revision, "revision");
63 this.path = requireNonNull(path, "path");
64 this.type = requireNonNull(type, "type");
65 this.content = content;
66 this.rawContent = rawContent;
67 this.templateRevision = templateRevision;
68 url = PROJECTS_PREFIX + '/' + projectName + REPOS + '/' + repoName + CONTENTS + path;
69 }
70
71 @JsonProperty
72 public Revision revision() {
73 return revision;
74 }
75
76 @Nullable
77 @JsonProperty
78 public Revision templateRevision() {
79 return templateRevision;
80 }
81
82 @JsonProperty
83 public String path() {
84 return path;
85 }
86
87 @Deprecated
88 @JsonProperty
89 public EntryType type() {
90 return type;
91 }
92
93 @JsonProperty
94 @Nullable
95 public T content() {
96 return content;
97 }
98
99 @JsonProperty
100 @Nullable
101 public String rawContent() {
102 return rawContent;
103 }
104
105 @JsonProperty
106 @Nullable
107 public String url() {
108 return url;
109 }
110
111 @Override
112 public String toString() {
113 return MoreObjects.toStringHelper(this).omitNullValues()
114 .add("revision", revision)
115 .add("templateRevision", templateRevision)
116 .add("path", path)
117 .add("type", type)
118 .add("content", content).toString();
119 }
120 }