подскажите чего в 26 строке не пускает
Exception in thread "main" java.lang.NullPointerException
at com.javarush.task.task22.task2208.Solution.getQuery(Solution.java:26)
at com.javarush.task.task22.task2208.Solution.main(Solution.java:18)
package com.javarush.task.task22.task2208;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
/*
Формируем WHERE
*/
public class Solution {
public static void main(String[] args) {
Map<String, String> map = new HashMap<>();
map.put("name", null);
map.put("country", null);
map.put("city", null);
map.put("age", "fefewqw");
System.out.println(map);
getQuery(map);
System.out.println(getQuery(map));
}
public static String getQuery(Map<String, String> params) {
StringBuilder stringBuilder = null;
String s = "";
for (Map.Entry<String, String> map : params.entrySet()) {
if (map.getValue()!=null&&!map.getValue().equals("")) {
s = String.valueOf(stringBuilder.append(String.format("%s = '%s' and ", map.getKey(), map.getValue())));
}
}
String string;
string = s;
if (string.length()==0) {
string = "";
}
else {
stringBuilder.reverse();
stringBuilder.replace(0, 5, "");
stringBuilder.reverse();
string = String.valueOf(stringBuilder);
}
return string;
}
}