All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.stewseo.client.json.JsonpMapper Maven / Gradle / Ivy

Go to download

java client to build api objects, handle http transport, and parse/deserialize/serialize json to/from json

There is a newer version: 1.8.0
Show newest version
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