public static String joinClauses(final String separator,final String... clauses){
  StringBuilder sql=new StringBuilder();
  if (clauses != null) {
    for (    String c : clauses) {
      if (c != null) {
        if (sql.length() > 0) {
          sql.append(separator);
        }
        sql.append(c);
      }
    }
  }
  if (sql.length() > 0) {
    return sql.toString();
  }
 else {
    return null;
  }
}

public static String joinClauses ( final String separator , final String ... clauses ) { StringBuilder sql = new StringBuilder ( ) ; if ( clauses != null ) { for ( String c : clauses ) { if ( c != null ) { if ( sql . length ( ) > 0 ) { sql . append ( separator ) ; } sql . append ( c ) ; } } } if ( sql . length ( ) > 0 ) { return sql . toString ( ) ; } else { return null ; } }
joins not null clauses to a complete string .
