Class SQL


  • public final class SQL
    extends java.lang.Object
    SQL request builder entry point and utility methods
    Since:
    0.1
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static ClausesBuilder clauses()
      Initialize a new clauses builder
      static <T> ClausesBuilder clauses​(java.lang.String column, ClauseMaker clause, T value)
      Initialize a new clauses builder and add the first clause if vaue is valid
      static <T> ClausesBuilder clauses​(java.lang.String column, ClauseMaker clause, T value, ValueChecker<T> checker)
      Initialize a new clauses builder and add the first clause if vaue is valid
      static <T> ClausesBuilder clauses​(java.lang.String column, ClauseMaker clause, T value1, T value2)
      Initialize a new clauses builder and add the first clause if vaue is valid
      static <T> ClausesBuilder clauses​(java.lang.String column, ClauseMaker clause, T value1, T value2, ValueChecker<T> checker)
      Initialize a new clauses builder and add the first clause if vaue is valid
      static DeleteBuilder delete​(java.lang.String table)
      Initialize a new delete builder
      static java.lang.String formatText​(java.lang.Object value)
      Format value for text column adding quote before and after value.
      Object will be cast into String with toString() method.
      static java.util.List<java.lang.String> formatText​(java.util.Collection<?> values)
      Format values for text column adding quote before and after value.
      Object will be cast into String with toString() method.
      static <T> boolean isValidValue​(T value)
      Check if value is null or empty (for String and Collection).
      This is the value ValueChecker which is used ot check value validity.
      static SelectBuilder select()
      Initialize a new select builder
      static <T> java.lang.String toSQLList​(java.util.Collection<T> values)
      Format value collection for SQL query (i.e for IN clause)
      static UpdateBuilder update​(java.lang.String table)
      Initialize a new update builder
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • update

        public static UpdateBuilder update​(java.lang.String table)
        Initialize a new update builder
        Parameters:
        table - the table to update
        Returns:
        the new UpdateBuilder
      • delete

        public static DeleteBuilder delete​(java.lang.String table)
        Initialize a new delete builder
        Parameters:
        table - the table to delete
        Returns:
        the new DeleteBuilder
      • clauses

        public static <T> ClausesBuilder clauses​(java.lang.String column,
                                                 ClauseMaker clause,
                                                 T value)
        Initialize a new clauses builder and add the first clause if vaue is valid
        Type Parameters:
        T - the value type
        Parameters:
        column - the column
        clause - the clause maker
        value - the value
        Returns:
        the new ClausesBuilder
      • clauses

        public static <T> ClausesBuilder clauses​(java.lang.String column,
                                                 ClauseMaker clause,
                                                 T value,
                                                 ValueChecker<T> checker)
        Initialize a new clauses builder and add the first clause if vaue is valid
        Type Parameters:
        T - the value type
        Parameters:
        column - the column
        clause - the clause maker
        value - the value
        checker - the value checker to use
        Returns:
        the new ClausesBuilder
      • clauses

        public static <T> ClausesBuilder clauses​(java.lang.String column,
                                                 ClauseMaker clause,
                                                 T value1,
                                                 T value2)
        Initialize a new clauses builder and add the first clause if vaue is valid
        Type Parameters:
        T - the value type
        Parameters:
        column - the column
        clause - the clause maker
        value1 - the first value
        value2 - the second value
        Returns:
        the new ClausesBuilder
      • clauses

        public static <T> ClausesBuilder clauses​(java.lang.String column,
                                                 ClauseMaker clause,
                                                 T value1,
                                                 T value2,
                                                 ValueChecker<T> checker)
        Initialize a new clauses builder and add the first clause if vaue is valid
        Type Parameters:
        T - the value type
        Parameters:
        column - the column
        clause - the clause maker
        value1 - the first value
        value2 - the second value
        checker - the value checker to use
        Returns:
        the new ClausesBuilder
      • formatText

        public static java.lang.String formatText​(java.lang.Object value)
        Format value for text column adding quote before and after value.
        Object will be cast into String with toString() method.
        Parameters:
        value - the value
        Returns:
        the formatter value
      • formatText

        public static java.util.List<java.lang.String> formatText​(java.util.Collection<?> values)
        Format values for text column adding quote before and after value.
        Object will be cast into String with toString() method.
        Parameters:
        values - the values
        Returns:
        the formatter values
      • toSQLList

        public static <T> java.lang.String toSQLList​(java.util.Collection<T> values)
        Format value collection for SQL query (i.e for IN clause)
        Type Parameters:
        T - the collection type
        Parameters:
        values - the values
        Returns:
        the SQL list
      • isValidValue

        public static <T> boolean isValidValue​(T value)
        Check if value is null or empty (for String and Collection).
        This is the value ValueChecker which is used ot check value validity.
        Type Parameters:
        T - the value type
        Parameters:
        value - the value
        Returns:
        true is value is not null, false otherwise