001/* 002 * SPDX-FileCopyrightText: none 003 * SPDX-License-Identifier: CC0-1.0 004 */ 005 006package dev.metaschema.databind.io.yaml; 007 008import com.fasterxml.jackson.core.JsonFactory; 009 010import dev.metaschema.core.model.IBoundObject; 011import dev.metaschema.databind.io.json.DefaultJsonSerializer; 012import dev.metaschema.databind.io.yaml.impl.YamlFactoryFactory; 013import dev.metaschema.databind.model.IBoundDefinitionModelAssembly; 014import edu.umd.cs.findbugs.annotations.NonNull; 015 016/** 017 * Serializes bound Java objects to YAML content. 018 * 019 * @param <CLASS> 020 * the Java type of the bound object to serialize 021 */ 022public class DefaultYamlSerializer<CLASS extends IBoundObject> 023 extends DefaultJsonSerializer<CLASS> { 024 025 /** 026 * Construct a new YAML serializer that will generate YAML content based on data 027 * in the bound class identified by the {@code classBinding}. 028 * 029 * @param definition 030 * the bound class information for the Java type this serializer is 031 * operating on 032 */ 033 public DefaultYamlSerializer(@NonNull IBoundDefinitionModelAssembly definition) { 034 super(definition); 035 } 036 037 @Override 038 protected JsonFactory newFactoryInstance() { 039 return YamlFactoryFactory.newGeneratorFactoryInstance(getConfiguration()); 040 } 041}