private static Predicate join ( final String joinWord , final List < Predicate > preds ) { return new Predicate ( ) { public void init ( AbstractSqlCreator creator ) { for ( Predicate p : preds ) { p . init ( creator ) ; } } public String toSql ( ) { StringBuilder sb = new StringBuilder ( ) . append ( "(" ) ; boolean first = true ; for ( Predicate p : preds ) { if ( ! first ) { sb . append ( " " ) . append ( joinWord ) . append ( " " ) ; } sb . append ( p . toSql ( ) ) ; first = false ; } return sb . append ( ")" ) . toString ( ) ; } } ; }
Factory for and and or predicates .