io.github.stewseo.client.json.JsonpMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of yelp-fusion-client Show documentation
Show all versions of yelp-fusion-client Show documentation
java client to build api objects, handle http transport, and parse/deserialize/serialize json to/from json
package io.github.stewseo.client.json;
import jakarta.json.spi.JsonProvider;
import jakarta.json.stream.JsonGenerator;
import jakarta.json.stream.JsonParser;
import javax.annotation.Nullable;
import java.lang.reflect.Type;
public interface JsonpMapper {
JsonProvider jsonProvider();
default T deserialize(JsonParser parser, Class clazz) {
return deserialize(parser, (Type)clazz);
}
T deserialize(JsonParser parser, Type type);
void serialize(T value, JsonGenerator generator);
default boolean ignoreUnknownFields() {
return true;
}
@Nullable
default T attribute(String name) {
return null;
}
/**
* Get a named attribute associated to this mapper, with a default value.
*/
default T attribute(String name, T defaultValue) {
T v = attribute(name);
return v != null ? v : defaultValue;
}
/**
* Create a new mapper with an additional attribute.
*
* The {@link JsonpMapperFeatures} class contains the names of attributes that all implementations of
* JsonpMapper
must implement.
*
* @see JsonpMapperFeatures
*/
JsonpMapper withAttribute(String name, T value);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy