Class Lambda2Sql


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

      • Lambda2Sql

        public Lambda2Sql()
    • Method Detail

      • 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.