I'm sure my returned string meets the requirements - is there a 'special' case I haven't thought of?
public static String getQuery(Map<String, String> params) {

        StringBuilder sb = new StringBuilder();
        Formatter fm = new Formatter(sb);

        Iterator<Map.Entry<String, String>> iterator = map.entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry<String, String> entry = iterator.next();
            if (entry.getValue() == null || entry.getKey() == null) { continue; }
            else {
                fm.format("%s = '%s'", entry.getKey(), entry.getValue());
                sb.append(" and ");
            }
        }
        if (sb.length() > 6) {
            sb.delete(sb.length() - 5, sb.length() - 1);
            return sb.toString();
        }
        else return "";

    }