Package net.pl3x.map.core.metrics
Class Metrics.JsonObjectBuilder
java.lang.Object
net.pl3x.map.core.metrics.Metrics.JsonObjectBuilder
- Enclosing class:
Metrics
An extremely simple JSON builder.
While this class is neither feature-rich nor the most performant one, it's sufficient for its use-case.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A super simple representation of a JSON object. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription@NotNull Metrics.JsonObjectBuilder
appendField
(@NotNull String key, int value) Appends an integer field to the JSON.@NotNull Metrics.JsonObjectBuilder
appendField
(@NotNull String key, @Nullable String value) Appends a string field to the JSON.@NotNull Metrics.JsonObjectBuilder
appendField
(@NotNull String key, @NotNull Metrics.JsonObjectBuilder.JsonObject[] values) Appends an object array to the JSON.@NotNull Metrics.JsonObjectBuilder
appendField
(@NotNull String key, @Nullable Metrics.JsonObjectBuilder.JsonObject object) Appends an object to the JSON.@NotNull Metrics.JsonObjectBuilder.JsonObject
build()
Builds the JSON string and invalidates this builder.
-
Constructor Details
-
JsonObjectBuilder
public JsonObjectBuilder()
-
-
Method Details
-
appendField
@NotNull public @NotNull Metrics.JsonObjectBuilder appendField(@NotNull @NotNull String key, @Nullable @Nullable String value) Appends a string field to the JSON.- Parameters:
key
- The key of the field.value
- The value of the field.- Returns:
- A reference to this object.
-
appendField
@NotNull public @NotNull Metrics.JsonObjectBuilder appendField(@NotNull @NotNull String key, int value) Appends an integer field to the JSON.- Parameters:
key
- The key of the field.value
- The value of the field.- Returns:
- A reference to this object.
-
appendField
@NotNull public @NotNull Metrics.JsonObjectBuilder appendField(@NotNull @NotNull String key, @Nullable @Nullable Metrics.JsonObjectBuilder.JsonObject object) Appends an object to the JSON.- Parameters:
key
- The key of the field.object
- The object.- Returns:
- A reference to this object.
-
appendField
@NotNull public @NotNull Metrics.JsonObjectBuilder appendField(@NotNull @NotNull String key, @NotNull @NotNull Metrics.JsonObjectBuilder.JsonObject[] values) Appends an object array to the JSON.- Parameters:
key
- The key of the field.values
- The integer array.- Returns:
- A reference to this object.
-
build
Builds the JSON string and invalidates this builder.- Returns:
- The built JSON string.
-