Skip to content
This repository was archived by the owner on Dec 18, 2025. It is now read-only.

Commit 29838ee

Browse files
shaileshmishrashaileshmishra
authored andcommitted
💡 Documenting source code
1 parent 879f91d commit 29838ee

File tree

2 files changed

+101
-0
lines changed

2 files changed

+101
-0
lines changed

src/main/java/com/contentstack/gqlspring/GQL.java

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
import java.util.Arrays;
1313
import java.util.List;
1414

15+
/**
16+
* The type Gql.
17+
*/
1518
final class GQL {
1619

1720
private final int id;
@@ -21,6 +24,11 @@ final class GQL {
2124
private final JSONObject queryJson;
2225
private final HttpHeaders headers;
2326

27+
/**
28+
* Instantiates a new Gql.
29+
*
30+
* @param builder the builder
31+
*/
2432
public GQL(Builder builder) {
2533
this.id = builder.id;
2634
this.tag = builder.tag;
@@ -42,6 +50,12 @@ public String toString() {
4250
'}';
4351
}
4452

53+
/**
54+
* Fetch json node.
55+
*
56+
* @return the json node
57+
* @throws JsonProcessingException the json processing exception
58+
*/
4559
public JsonNode fetch() throws JsonProcessingException {
4660
RestTemplate restTemplate = new RestTemplate();
4761
HttpEntity<JSONObject> entity = new HttpEntity<JSONObject>(queryJson, this.headers);
@@ -58,6 +72,12 @@ public JsonNode fetch() throws JsonProcessingException {
5872
}
5973
}
6074

75+
/**
76+
* Model it.
77+
*
78+
* @param <T> the type parameter
79+
* @param responseString the response string
80+
*/
6181
public <T> void modelIt(String responseString) {
6282
try {
6383
ObjectMapper mapper = new ObjectMapper();
@@ -72,6 +92,9 @@ public <T> void modelIt(String responseString) {
7292
}
7393
}
7494

95+
/**
96+
* The type Builder.
97+
*/
7598
public static class Builder {
7699

77100
private int id;
@@ -84,20 +107,43 @@ public static class Builder {
84107
private Builder() {
85108
}
86109

110+
/**
111+
* New instance builder.
112+
*
113+
* @return the builder
114+
*/
87115
public static Builder newInstance() {
88116
return new Builder();
89117
}
90118

119+
/**
120+
* Sets id.
121+
*
122+
* @param id the id
123+
* @return the id
124+
*/
91125
public Builder setId(int id) {
92126
this.id = id;
93127
return this;
94128
}
95129

130+
/**
131+
* Sets tag.
132+
*
133+
* @param tag the tag
134+
* @return the tag
135+
*/
96136
public Builder setTag(String tag) {
97137
this.tag = tag;
98138
return this;
99139
}
100140

141+
/**
142+
* Sets node.
143+
*
144+
* @param node the node
145+
* @return the node
146+
*/
101147
public Builder setNode(String node) {
102148
if (node != null && !node.isEmpty()) {
103149
this.nodeSplitter = node.split(":");
@@ -109,18 +155,36 @@ public Builder setNode(String node) {
109155
return this;
110156
}
111157

158+
/**
159+
* Sets url.
160+
*
161+
* @param url the url
162+
* @return the url
163+
*/
112164
public Builder setUrl(String url) {
113165
this.url = url;
114166
return this;
115167
}
116168

169+
/**
170+
* Sets query string.
171+
*
172+
* @param queryString the query string
173+
* @return the query string
174+
*/
117175
public Builder setQueryString(String queryString) {
118176
JSONObject jsonObject = new JSONObject();
119177
jsonObject.appendField("query", queryString);
120178
this.queryJson = jsonObject;
121179
return this;
122180
}
123181

182+
/**
183+
* Sets header.
184+
*
185+
* @param access_token the access token
186+
* @return the header
187+
*/
124188
public Builder setHeader(String access_token) {
125189
final HttpHeaders headers = new HttpHeaders();
126190
ArrayList<MediaType> acceptableMediaTypes = new ArrayList<MediaType>();
@@ -131,6 +195,11 @@ public Builder setHeader(String access_token) {
131195
return this;
132196
}
133197

198+
/**
199+
* Build gql.
200+
*
201+
* @return the gql
202+
*/
134203
public GQL build() {
135204
// Do some validation part if required values are not provided
136205
// if (url.isEmpty()){

src/main/java/com/contentstack/gqlspring/GQLTestApplication.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,32 @@
1111
import org.springframework.web.bind.annotation.RequestMapping;
1212
import org.springframework.web.bind.annotation.RestController;
1313

14+
/**
15+
* The type Gql test application.
16+
*/
1417
@SpringBootApplication
1518
@RestController
1619
@Slf4j
1720
@Validated
1821
@RequestMapping(path = "api")
1922
public class GQLTestApplication {
2023

24+
/**
25+
* The entry point of application.
26+
*
27+
* @param args the input arguments
28+
*/
2129
public static void main(String[] args) {
2230
SpringApplication.run(GQLTestApplication.class, args);
2331
}
2432

2533

34+
/**
35+
* Gets products.
36+
*
37+
* @return the products
38+
* @throws JsonProcessingException the json processing exception
39+
*/
2640
@GetMapping(value = "/product")
2741
public JsonNode getProducts() throws JsonProcessingException {
2842
GQL gqlInstance = GQL.Builder.newInstance()
@@ -36,6 +50,12 @@ public JsonNode getProducts() throws JsonProcessingException {
3650
}
3751

3852

53+
/**
54+
* Gets about.
55+
*
56+
* @return the about
57+
* @throws JsonProcessingException the json processing exception
58+
*/
3959
@GetMapping(value = "/about")
4060
public JsonNode getAbout() throws JsonProcessingException {
4161
GQL gqlInstance = GQL.Builder.newInstance()
@@ -58,6 +78,12 @@ public JsonNode getAbout() throws JsonProcessingException {
5878
}
5979

6080

81+
/**
82+
* Gets banner.
83+
*
84+
* @return the banner
85+
* @throws JsonProcessingException the json processing exception
86+
*/
6187
@GetMapping(value = "/banner")
6288
public JsonNode getBanner() throws JsonProcessingException {
6389
GQL gqlInstance = GQL.Builder.newInstance()
@@ -86,6 +112,12 @@ public JsonNode getBanner() throws JsonProcessingException {
86112
}
87113

88114

115+
/**
116+
* Gets contact.
117+
*
118+
* @return the contact
119+
* @throws JsonProcessingException the json processing exception
120+
*/
89121
@GetMapping(value = "/contact")
90122
public JsonNode getContact() throws JsonProcessingException {
91123
GQL gqlInstance = GQL.Builder.newInstance()

0 commit comments

Comments
 (0)