src/main/java/com/alay/util/macos/StatementUtil.java
/**
     * Build SELECT statement to fetch messages.
     *
     * @param chats shall not be null. Empty collection means no filter.
     * @param since can be null.
     * @return SELECT statement.
     */
Build SELECT statement to fetch messages.
@param chats shall not be null. Empty collection means no filter.
@param since can be null.
@return SELECT statement.
Build SELECT statement to fetch messages . @param chats shall not be null . Empty collection means no filter . @param since can be null . @return SELECT statement .
static String buildSelect(Collection<String> chats, LocalDateTime since) {
        StringBuilder statementBuilder = new StringBuilder(BASE_SELECT);
        if (since != null || isNotBlank(chats)) {
            statementBuilder.append(" WHERE");
            int overhead = 0;
            if (since != null) {
                statementBuilder
                        .append(" m.date > ")
                        .append(DateFormatUtil.dateTimeToApple(since))
                        .append(" AND");
                overhead = " AND".length();
            }
            if (isNotBlank(chats)) {
                for (String chat : chats) {
                    statementBuilder.append(format(" c.chat_identifier LIKE ''%{0}%'' OR", chat));
                }
                overhead = " OR".length();
            }
            statementBuilder.setLength(statementBuilder.length() - overhead);
        }
        statementBuilder.append(" ORDER BY m.date");
        return statementBuilder.toString();
    }
static String buildSelect ( Collection < String > chats , LocalDateTime since ) { StringBuilder statementBuilder = new StringBuilder ( BASE_SELECT ) ; if ( since != null || isNotBlank ( chats ) ) { statementBuilder . append ( " WHERE" ) ; int overhead = 0 ; if ( since != null ) { statementBuilder . append ( " m.date > " ) . append ( DateFormatUtil . dateTimeToApple ( since ) ) . append ( " AND" ) ; overhead = " AND" . length ( ) ; } if ( isNotBlank ( chats ) ) { for ( String chat : chats ) { statementBuilder . append ( format ( " c.chat_identifier LIKE ''%{0}%'' OR" , chat ) ) ; } overhead = " OR" . length ( ) ; } statementBuilder . setLength ( statementBuilder . length ( ) - overhead ) ; } statementBuilder . append ( " ORDER BY m.date" ) ; return statementBuilder . toString ( ) ; }
Build SELECT statement to fetch messages.
Build SELECT statement to fetch messages .