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

com.fasterxml.jackson.jakarta.rs.yaml.YAMLEndpointConfig Maven / Gradle / Ivy

Go to download

Functionality to handle YAML input/output for Jakarta-RS implementations (like Jersey and RESTeasy) using standard Jackson data binding.

The newest version!
package com.fasterxml.jackson.jakarta.rs.yaml;

import java.lang.annotation.Annotation;

import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.cfg.MapperConfig;

import com.fasterxml.jackson.jakarta.rs.cfg.EndpointConfigBase;

/**
 * Container class for figuring out annotation-based configuration
 * for Jakarta-RS end points.
 */
public class YAMLEndpointConfig
        extends EndpointConfigBase
{
    protected YAMLEndpointConfig(MapperConfig config) {
        super(config);
    }

    public static YAMLEndpointConfig forReading(ObjectReader reader,
                                                Annotation[] annotations) {
        return new YAMLEndpointConfig(reader.getConfig())
                .add(annotations, false)
                .initReader(reader);
    }

    public static YAMLEndpointConfig forWriting(ObjectWriter writer,
                                                Annotation[] annotations) {
        return new YAMLEndpointConfig(writer.getConfig())
                .add(annotations, true)
                .initWriter(writer)
        ;
    }

    @Override
    public Object modifyBeforeWrite(Object value) {
        // nothing to add
        return value;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy