private String getStringPredicate ( String fieldName , List < String > filterValues , List < Object > prms ) { if ( filterValues != null && ! filterValues . isEmpty ( ) ) { String res = "" ; for ( String filterValue : filterValues ) { if ( filterValue == null ) { continue ; } if ( ! filterValue . isEmpty ( ) ) { prms . add ( filterValue ) ; if ( filterValue . contains ( "%" ) ) { res += String . format ( "(%s LIKE ?) OR " , fieldName ) ; } else { res += String . format ( "(%s = ?) OR " , fieldName ) ; } } else { res += String . format ( "(%s IS NULL OR %s = '') OR " , fieldName , fieldName ) ; } } if ( ! res . isEmpty ( ) ) { res = "AND (" + res . substring ( 0 , res . length ( ) - 4 ) + ") " ; return res ; } } return "" ; }
GetJob helper - String predicates are all created the same way so this factors some code .