Interface Renderer<T>

Type Parameters:
T - The type of things this renderer supports

public interface Renderer<T>
Renders constraints. This indirection exists to decouple the definition of a constraint from the underlying database.
Since:
1.7.0
Author:
Michael J. Simons
Soundtrack
Anthrax - Spreading The Disease
  • Method Details

    • get

      static <T> Renderer<T> get(Renderer.Format format, T type)
      Retrieves a renderer for the given Renderer.Format and given item.
      Type Parameters:
      T - The type of the item
      Parameters:
      format - The format in which to render
      type - The item that should be rendered
      Returns:
      A renderer for the given type
      Throws:
      UnsupportedOperationException - in case the combination of format and type is not supported
    • get

      static <T> Renderer<T> get(Renderer.Format format, Class<T> type)
      Retrieves a renderer for the given Renderer.Format and the type matching type.
      Type Parameters:
      T - The types specific type
      Parameters:
      format - The format in which to render
      type - The type that should be rendered
      Returns:
      A renderer for the given type
      Throws:
      UnsupportedOperationException - in case the combination of format and type is not supported
    • render

      void render(T item, RenderConfig config, OutputStream target) throws IOException
      Renders a schema item.
      Parameters:
      item - The item to be rendered
      config - The context in which the constraint is to be rendered.
      target - The target to write to. Will not be closed.
      Throws:
      IllegalStateException - in case a given item cannot be rendered with the features requested in the given context.
      IOException - If rendering fails due to issues with the target
    • render

      default String render(T item, RenderConfig config)
      Renders a schema item.
      Parameters:
      item - The item to be rendered
      config - The configuration to render
      Returns:
      The textual representation of the item in the given context, ready to be executed.
      Throws:
      UncheckedIOException - any IOException from render(T, RenderConfig, OutputStream) is rethrown here