Interface JsonObjectParser<T>

All Superinterfaces:
JsonParser<T>
All Known Implementing Classes:
ProductParsers.EmptyProductParser, ProductParsers.VariadicProductParser

public interface JsonObjectParser<T> extends JsonParser<T>
  • Method Summary

    Modifier and Type
    Method
    Description
    default <S> JsonObjectParser<S>
    map(Convert<T,S> transform)
    Adapts this parser losslessly from one domain type to another with a two-way conversion.
    default <S> JsonObjectParser<S>
    map(Function<T,S> from, Function<S,T> to)
    Adapts this parser losslessly from one domain type to another.
    javax.json.JsonObject
    unparse(T value)
    Produces a JSON document representing the given value.

    Methods inherited from interface gov.nasa.jpl.aerie.json.JsonParser

    getSchema, getSchema, parse
  • Method Details

    • unparse

      javax.json.JsonObject unparse(T value)
      Description copied from interface: JsonParser
      Produces a JSON document representing the given value.

      The document produced by this method must validate against the schema returned by JsonParser.getSchema(), and must be parsed successfully by JsonParser.parse(JsonValue) into a value equal to the one given here.

      Specified by:
      unparse in interface JsonParser<T>
      Parameters:
      value - a domain value to encode in JSON
      Returns:
      a JSON document representing the given value
    • map

      default <S> JsonObjectParser<S> map(Convert<T,S> transform)
      Description copied from interface: JsonParser
      Adapts this parser losslessly from one domain type to another with a two-way conversion.

      The data types most convenient for building parsers are not always the ones we actually want to end up with in the business domain. This method turns a parser that works with one (parsing-relevant) type into a parser that works with another (domain-relevant) type (typically the domain-relevant one).

      To do this, we need to know the precise relationship between the two types. Specifically, we need a way to turn any value of one into a value of the other, and vice versa. This is captured by the Convert parameter, which provides a pair of forward and backward transformations.

      Specified by:
      map in interface JsonParser<T>
      Type Parameters:
      S - the new domain type to convert to
      Parameters:
      transform - the reversible transformation faithfully mapping between T objects and S objects
      Returns:
      a parser supporting the same JSON documents as this parser, but for domain type S.
    • map

      default <S> JsonObjectParser<S> map(Function<T,S> from, Function<S,T> to)
      Description copied from interface: JsonParser
      Adapts this parser losslessly from one domain type to another.

      The data types most convenient for building parsers are not always the ones we actually want to end up with in the business domain. This method turns a parser that works with one (parsing-relevant) type into a parser that works with another (domain-relevant) type (typically the domain-relevant one).

      To do this, we need to know the precise relationship between the two types. Specifically, we need a way to turn any value of one into a value of the other, and vice versa.

      Specified by:
      map in interface JsonParser<T>
      Type Parameters:
      S - the new domain type to convert to
      Parameters:
      from - an infallible transformation from the source type to the target type
      to - an infallible transformation to the source type from the target type
      Returns:
      a parser supporting the same JSON documents as this parser, but for domain type S.