Class Lambda2Sql


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

      • Lambda2Sql

        public Lambda2Sql()
    • Method Detail

      • toSql

        public static java.lang.String toSql​(SerializedFunctionalInterface functionalInterface,
                                             java.lang.String prefix)
        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.
        prefix - An optional prefix to proceed the column name. Usually it is supposed to be used to reference the column name including the table name.
        Returns:
        A String describing the SQL where condition.