Skip to content

Commit 181850d

Browse files
committed
Allow returning null in PostEndpoint#getJsonElement
- Add basic javadoc
1 parent c86f20a commit 181850d

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/main/java/net/earthmc/emcapi/object/endpoint/PostEndpoint.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,28 @@ public String lookup(JsonArray queryArray, @Nullable JsonObject template, @Nulla
2727
if (object == null) {
2828
continue;
2929
}
30-
jsonArray.add(getTemplateJsonElement(object, template, key));
30+
JsonElement formatted = getTemplateJsonElement(object, template, key);
31+
if (formatted == null) {
32+
continue;
33+
}
34+
jsonArray.add(formatted);
3135
}
3236

3337
return jsonArray.toString();
3438
}
3539

40+
/**
41+
* @param element The query provided by the user
42+
* @param key The API key, if any provided
43+
* @return The queried object if found, otherwise null
44+
*/
3645
public abstract T getObjectOrNull(JsonElement element, @Nullable String key);
3746

47+
/**
48+
* @param object The object to describe
49+
* @param key The API key, if any provided
50+
* @return A JsonElement describing this object, or null if anything went wrong (E.g. cooldown, unauthorized key)
51+
*/
3852
public abstract JsonElement getJsonElement(T object, @Nullable String key);
3953

4054
public JsonElement getTemplateJsonElement(T object, JsonObject template, @Nullable String key) {

0 commit comments

Comments
 (0)