SimpleParser

public abstract class SimpleParser<T, U> extends Parser<T>

A Parser counterpart to DefaultParser for subclasses that parse a pre-shaped input of type U directly, rather than receiving the metadata-plus-time-series split DefaultParser performs.

parse is not implemented here: it always returns null, since this class' parsing entry point is parse(U).

Author

Sylvester Sefa-Yeboah

Since

1.7.0

Parameters

<T>

the response type produced by this parser

<U>

the pre-shaped input type this parser consumes

Constructors

Link copied to clipboard
public void SimpleParser()

Functions

Link copied to clipboard
public static N getNumberFromString<N extends Number>(String s, Function<String, N> parser)
Link copied to clipboard
public abstract T onParseError(String error)
Produces the value this parser returns in place of a response object when the reply cannot be parsed, for example an empty or unrecognizable JSON body.
Link copied to clipboard
public abstract T parse(U data)
Parses a pre-shaped input into a response object.
public final T parse(Map<String, Object> object)
Always returns null.
Link copied to clipboard
public static Map<String, Object> parseJSON(String responseBody)
Decodes a raw JSON response body into a generic String-keyed map, with the NoneableDouble/NoneableLong adapters registered so numeric-or-"None" fields decode correctly.
public static U parseJSON<U>(String responseBody, Class<U> c)
Decodes a raw JSON response body directly into an instance of c, with the NoneableDouble/NoneableLong adapters registered so numeric-or-"None" fields decode correctly.
Link copied to clipboard
public static List<U> parseJSONList<U>(Object object, Class<U> klass)
Converts an already-decoded JSON value, typically a List produced by parseJSON, into a List of klass instances, with the NoneableDouble/NoneableLong adapters registered so numeric-or-"None" fields decode correctly.
Link copied to clipboard
public static String toJSON(Map<String, Object> data)
Encodes a String-keyed map back into a JSON string, with the NoneableDouble/NoneableLong adapters registered.