Class Metrics.JsonObjectBuilder

java.lang.Object
net.pl3x.map.core.metrics.Metrics.JsonObjectBuilder
Enclosing class:
Metrics

public static class Metrics.JsonObjectBuilder extends Object
An extremely simple JSON builder.

While this class is neither feature-rich nor the most performant one, it's sufficient for its use-case.

  • 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

      @NotNull public @NotNull Metrics.JsonObjectBuilder.JsonObject build()
      Builds the JSON string and invalidates this builder.
      Returns:
      The built JSON string.