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

org.sdase.commons.shared.asyncapi.FinalBuilder Maven / Gradle / Ivy

Go to download

A libraries to bootstrap services easily that follow the patterns and specifications promoted by the SDA SE

There is a newer version: 7.0.88
Show newest version
package org.sdase.commons.shared.asyncapi;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.dataformat.yaml.YAMLMapper;
import java.io.UncheckedIOException;

public interface FinalBuilder {
  /**
   * Generates a new JSON schema for the supplied class.
   *
   * @return A JSON object for the JSON schema.
   */
  JsonNode generate();

  /**
   * Generates a new JSON schema for the supplied class.
   *
   * @return A YAML representation for the JSON schema.
   * @throws UncheckedIOException if json processing fails
   */
  default String generateYaml() {
    try {
      return YAMLMapper.builder().build().writeValueAsString(generate());
    } catch (JsonProcessingException e) {
      throw new UncheckedIOException("Error while converting JSON to YAML.", e);
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy