Class SqlPrintFormat

java.lang.Object
org.approvej.database.jdbc.SqlPrintFormat
All Implemented Interfaces:
org.approvej.print.PrintFormat<String>

@NullMarked public class SqlPrintFormat extends Object implements org.approvej.print.PrintFormat<String>
PrintFormat implementation for SQL strings that formats them with line breaks and indentation for readability.

Major SQL clauses (SELECT, FROM, WHERE, etc.) are placed on their own lines. Column lists and conditions are indented. This makes it easy to review SQL in approved files.

For example, SELECT id, name FROM users WHERE active = 1 ORDER BY name becomes:

 SELECT
   id,
   name
 FROM
   users
 WHERE
   active = 1
 ORDER BY
   name
 
  • Constructor Details

    • SqlPrintFormat

      public SqlPrintFormat()
      Default constructor.
  • Method Details

    • printer

      public org.approvej.print.Printer<String> printer()
      Specified by:
      printer in interface org.approvej.print.PrintFormat<String>
    • filenameExtension

      public String filenameExtension()
      Specified by:
      filenameExtension in interface org.approvej.print.PrintFormat<String>
    • sql

      public static SqlPrintFormat sql()
      Creates and returns a new SqlPrintFormat instance.
      Returns:
      the new instance