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 javax.annotation.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
39 private final String path;
40
41 private final EntryType type;
42
43 private final T content;
44
45 private final String url;
46
47 public EntryDto(Revision revision, String path, EntryType type,
48 String projectName, String repoName, @Nullable T content) {
49 this.revision = requireNonNull(revision, "revision");
50 this.path = requireNonNull(path, "path");
51 this.type = requireNonNull(type, "type");
52 this.content = content;
53 url = PROJECTS_PREFIX + '/' + projectName + REPOS + '/' + repoName + CONTENTS + path;
54 }
55
56 @JsonProperty
57 public Revision revision() {
58 return revision;
59 }
60
61 @JsonProperty
62 public String path() {
63 return path;
64 }
65
66 @JsonProperty
67 public EntryType type() {
68 return type;
69 }
70
71 @JsonProperty
72 @Nullable
73 public T content() {
74 return content;
75 }
76
77 @JsonProperty
78 @Nullable
79 public String url() {
80 return url;
81 }
82
83 @Override
84 public String toString() {
85 return MoreObjects.toStringHelper(this).omitNullValues()
86 .add("revision", revision)
87 .add("path", path)
88 .add("type", type)
89 .add("content", content).toString();
90 }
91 }