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

io.github.qsy7.serialization.modules.snakeyaml.Snakeyaml Maven / Gradle / Ivy

There is a newer version: 0.3.3
Show newest version
// Generated by delombok at Fri Apr 08 14:58:40 EDT 2022
package io.github.qsy7.serialization.modules.snakeyaml;

import io.github.qsy7.serialization.api.service.SerializationService;
import io.github.qsy7.serialization.api.service.YAML;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Serializable;
import javax.inject.Inject;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;

public class Snakeyaml implements SerializationService, YAML {
  /**
   * TODO: inject this later properly configured
   */
  protected transient Yaml yaml = new Yaml(new MessageRepresenter(), new DumperOptions());

  @Override
  public void serialize(Serializable data, OutputStream outputStream) {
    yaml.dump(data, new OutputStreamWriter(outputStream));
  }

  @Override
  public  EntityType deserialize(InputStream inputStream, Class entityClass) {
    return yaml.loadAs(inputStream, entityClass);
  }

  @Override
  public Serializable deserialize(InputStream inputStream) {
    return yaml.load(inputStream);
  }

  /**
   * TODO: inject this later properly configured
   */
  @java.lang.SuppressWarnings("all")
  public Yaml getYaml() {
    return this.yaml;
  }

  @Inject
  @java.lang.SuppressWarnings("all")
  public Snakeyaml() {
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy