Class Lambda2Sql

java.lang.Object
com.github.collinalpert.lambda2sql.Lambda2Sql

public class Lambda2Sql
extends Object
A utility class for converting java lambdas to SQL.
  • Constructor Details

  • Method Details

    • toSql

      public static String toSql​(SerializedFunctionalInterface functionalInterface, String tableName, boolean withBackticks)
      Converts a lambda expression to SQL.
      person -> person.getAge() > 50 && person.isActive() 
      Becomes a string:
      "age > 50 AND active" 
      Supported operators: >,>=,<,<=,=,!=,&&,||,!
      Parameters:
      functionalInterface - A FunctionalInterface lambda to convert.
      tableName - The table name which the column belongs to. This will explicitly reference the column. It is optional to specify this.
      withBackticks - Specifies if the table and the column name should be escaped with backticks. The default behavior is true.
      Returns:
      A String describing the SQL where condition.
    • toSql

      public static String toSql​(SerializedFunctionalInterface functionalInterface, String tableName)
    • toSql

      public static String toSql​(SerializedFunctionalInterface functionalInterface)