Class JsonObject

java.lang.Object
io.github.joke.conventionalversion.config.JsonObject

public class JsonObject extends Object
A parsed JSON object, read by key with the type each caller expects.

Every cast out of the untyped tree a JSON parser produces happens here, so the configuration layer above works against checked values. A key holding the wrong type is a malformed configuration and fails rather than being coerced or ignored, because a configuration this project cannot read is a configuration whose versions it cannot predict.

  • Constructor Details

  • Method Details

    • keys

      public Set<String> keys()
      The keys present, in the order the document declared them.
    • has

      public boolean has(String key)
    • string

      public Optional<String> string(String key)
    • bool

      public Optional<Boolean> bool(String key)
    • object

      public Optional<JsonObject> object(String key)
    • requireObject

      public JsonObject requireObject(String key)
      The object at a key that must be present, for a caller with nothing sensible to do without it.
    • strings

      public List<String> strings(String key)
      The elements of a string array, or empty when the key is absent.
    • objects

      public List<JsonObject> objects(String key, String nameKey)
      The elements of an array whose entries are either objects or bare names, with a bare name becoming an object carrying only nameKey. release-please accepts both shapes for its plugins array, and the reader above should not have to care which was used.
    • asObject

      @VisibleForTesting protected JsonObject asObject(String key, String nameKey, Object element)
    • elements

      @VisibleForTesting protected List<?> elements(String key)
    • present

      @VisibleForTesting protected List<?> present(List<?> list)
      A null element is dropped, for the same reason a null value is.
    • child

      @VisibleForTesting protected JsonObject child(String key, Map<?,?> map)
    • typed

      @VisibleForTesting protected <T> Optional<T> typed(String key, Class<T> type, String expected)
    • requireType

      @VisibleForTesting protected <T> T requireType(String key, Object value, Class<T> type, String expected)
    • describe

      @VisibleForTesting protected String describe(Object value)
    • path

      @VisibleForTesting protected String path(String key)