Skip to content
This repository was archived by the owner on Jan 5, 2019. It is now read-only.

Commit e3334d8

Browse files
committed
Improve javadoc
1 parent c4dbe5a commit e3334d8

2 files changed

Lines changed: 56 additions & 0 deletions

File tree

src/main/java/com/scorpiac/javarant/User.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ public static User byUsername(String username) {
8181
return byId(json.get("user_id").getAsInt());
8282
}
8383

84+
/**
85+
* Create a user from a JSON object.
86+
*
87+
* @param json The JSON object to create the user from.
88+
* @return The created user.
89+
*/
8490
static User fromJson(JsonObject json) {
8591
return new User(
8692
json.get("user_id").getAsInt(),
@@ -155,10 +161,16 @@ public boolean isFetched() {
155161
return fetched;
156162
}
157163

164+
/**
165+
* Get the link to the user.
166+
*/
158167
public String userLink() {
159168
return DevRant.link(DevRant.USER_URL + "/" + username);
160169
}
161170

171+
/**
172+
* Get the link to the user's avatar.
173+
*/
162174
public String avatarLink() {
163175
fetchData();
164176
return DevRant.AVATARS_URL + "/" + avatar;
@@ -185,61 +197,97 @@ public int getScore() {
185197
return score;
186198
}
187199

200+
/**
201+
* Get information about the user.
202+
*/
188203
public String getAbout() {
189204
fetchData();
190205
return about;
191206
}
192207

208+
/**
209+
* Get the user's location.
210+
*/
193211
public String getLocation() {
194212
fetchData();
195213
return location;
196214
}
197215

216+
/**
217+
* Get the user's skills.
218+
*/
198219
public String getSkills() {
199220
fetchData();
200221
return skills;
201222
}
202223

224+
/**
225+
* Get the user's GitHub username.
226+
*/
203227
public String getGithub() {
204228
fetchData();
205229
return github;
206230
}
207231

232+
/**
233+
* Get the rants that this user posted.
234+
*/
208235
public Rant[] getRants() {
209236
fetchData();
210237
return rants;
211238
}
212239

240+
/**
241+
* Get the rants that this user upvoted.
242+
*/
213243
public Rant[] getUpvoted() {
214244
fetchData();
215245
return upvoted;
216246
}
217247

248+
/**
249+
* Get this user's comments.
250+
*/
218251
public Comment[] getComments() {
219252
fetchData();
220253
return comments;
221254
}
222255

256+
/**
257+
* Get this user's favorites.
258+
*/
223259
public Rant[] getFavorites() {
224260
fetchData();
225261
return favorites;
226262
}
227263

264+
/**
265+
* Get the amount of rants that this user has posted.
266+
*/
228267
public int getRantsCount() {
229268
fetchData();
230269
return rantsCount;
231270
}
232271

272+
/**
273+
* Get the amount of rants that this user has upvoted.
274+
*/
233275
public int getUpvotedCount() {
234276
fetchData();
235277
return upvotedCount;
236278
}
237279

280+
/**
281+
* Get the amount of comments that this user has posted.
282+
*/
238283
public int getCommentsCount() {
239284
fetchData();
240285
return commentsCount;
241286
}
242287

288+
/**
289+
* Get the amount of rants that this user has favorited.
290+
*/
243291
public int getFavoritesCount() {
244292
fetchData();
245293
return favoritesCount;

src/main/java/com/scorpiac/javarant/Util.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ class Util {
1212
private Util() {
1313
}
1414

15+
/**
16+
* Create a list from a JSON array.
17+
*
18+
* @param json The JSON array to convert to a list.
19+
* @param converter The converter for converting individual JSON elements.
20+
* @param <T> The type to convert the elements to.
21+
* @return A list of elements converted from the JSON.
22+
*/
1523
static <T> List<T> jsonToList(JsonArray json, Function<JsonElement, T> converter) {
1624
List<T> result = new ArrayList<>(json.size());
1725
json.forEach(j -> result.add(converter.apply(j)));

0 commit comments

Comments
 (0)