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

io.quarkus.jackson.runtime.JacksonSupportRecorder Maven / Gradle / Ivy

There is a newer version: 3.17.0.CR1
Show newest version
package io.quarkus.jackson.runtime;

import java.util.Optional;
import java.util.function.Supplier;

import com.fasterxml.jackson.databind.PropertyNamingStrategies;

import io.quarkus.runtime.annotations.Recorder;

@Recorder
public class JacksonSupportRecorder {

    public Supplier supplier(Optional propertyNamingStrategyClassName) {
        return new Supplier<>() {
            @Override
            public JacksonSupport get() {
                return new JacksonSupport() {
                    @Override
                    public Optional configuredNamingStrategy() {
                        if (propertyNamingStrategyClassName.isPresent()) {
                            try {
                                var value = (PropertyNamingStrategies.NamingBase) Class
                                        .forName(propertyNamingStrategyClassName.get(), true,
                                                Thread.currentThread()
                                                        .getContextClassLoader())
                                        .getDeclaredConstructor().newInstance();
                                return Optional.of(value);
                            } catch (Exception e) {
                                // shouldn't happen as propertyNamingStrategyClassName is validated at build time
                                throw new RuntimeException(e);
                            }
                        }
                        return Optional.empty();
                    }
                };
            }
        };
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy