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.dataformat.yaml.YAMLFactory;
009
010import dev.metaschema.core.model.IBoundObject;
011import dev.metaschema.databind.io.json.DefaultJsonDeserializer;
012import dev.metaschema.databind.io.yaml.impl.YamlFactoryFactory;
013import dev.metaschema.databind.model.IBoundDefinitionModelAssembly;
014import edu.umd.cs.findbugs.annotations.NonNull;
015
016/**
017 * Deserializes YAML content into bound Java objects.
018 *
019 * @param <CLASS>
020 *          the Java type of the bound object to deserialize
021 */
022public class DefaultYamlDeserializer<CLASS extends IBoundObject>
023    extends DefaultJsonDeserializer<CLASS> {
024
025  /**
026   * Construct a new YAML deserializer that will parse the bound class identified
027   * by the {@code classBinding}.
028   *
029   * @param definition
030   *          the bound class information for the Java type this deserializer is
031   *          operating on
032   */
033  public DefaultYamlDeserializer(@NonNull IBoundDefinitionModelAssembly definition) {
034    super(definition);
035  }
036
037  /**
038   * {@inheritDoc}
039   * <p>
040   * This method provides a YAML version of the JSON factory.
041   *
042   * @return the factory
043   */
044  @Override
045  protected YAMLFactory newFactoryInstance() {
046    return YamlFactoryFactory.newParserFactoryInstance(getConfiguration());
047  }
048
049}