Source:
<code>public String deconstructSearchQuery(String searchQuery) { ArrayList<String> features = new ArrayList<>(); <START> if (searchQuery.isEmpty()) { <END> features.add("is null"); return features.toString(); } switch(searchQuery) { case "": features.add("is empty"); break; case "*": features.add("is just *"); break; case "?": features.add("is just ?"); break; case "~": features.add("is just ~"); break; case "searchTerms": features.add("is searchTerms"); break; } if (features.size() > 0) { return features.toString(); } if (searchQuery.contains("@")) { features.add("has @"); } if (searchQuery.contains("prefix:")) { features.add("is prefix"); } if (searchQuery.contains("insource:")) { features.add("is insource"); } if (searchQuery.contains("incategory:")) { features.add("is incategory"); } if (searchQuery.contains("intitle:")) { features.add("is intitle"); } if (searchQuery.substring(0, 1).equals("~")) { features.add("forces search results"); } if (searchQuery.substring(searchQuery.length() - 1).equals("?")) { features.add("ends with ?"); } for (SearchQueryFeatureRegex f : SearchQueryFeatureRegex.values()) { if (f.getPattern().matcher(searchQuery).find()) { features.add(f.getDescription()); } } int doubleQuotesCount = searchQuery.length() - searchQuery.replace("\"", "").length(); if (doubleQuotesCount > 0) { if (doubleQuotesCount == 1) { features.add("has one double quote"); } features.add((doubleQuotesCount % 2) == 0 ? "has even double quotes" : "has odd double quotes"); } if (features.size() == 0) { features.add("is simple"); } return features.toString(); }</code><technical_language>This return true if length of string is zero give a null pointer if is null. <LINK_1></technical_language>

Target:
public String deconstructSearchQuery(String searchQuery) { ArrayList<String> features = new ArrayList<>(); if (searchQuery == null) { features.add("is null"); return features.toString(); } switch(searchQuery) { case "": features.add("is empty"); break; case "*": features.add("is just *"); break; case "?": features.add("is just ?"); break; case "~": features.add("is just ~"); break; case "searchTerms": features.add("is searchTerms"); break; } if (features.size() > 0) { return features.toString(); } if (searchQuery.contains("@")) { features.add("has @"); } if (searchQuery.contains("prefix:")) { features.add("is prefix"); } if (searchQuery.contains("insource:")) { features.add("is insource"); } if (searchQuery.contains("incategory:")) { features.add("is incategory"); } if (searchQuery.contains("intitle:")) { features.add("is intitle"); } if (searchQuery.substring(0, 1).equals("~")) { features.add("forces search results"); } if (searchQuery.endsWith("?")) { features.add("ends with ?"); } for (SearchQueryFeatureRegex f : SearchQueryFeatureRegex.values()) { if (f.getPattern().matcher(searchQuery).find()) { features.add(f.getDescription()); } } int doubleQuotesCount = searchQuery.length() - searchQuery.replace("\"", "").length(); if (doubleQuotesCount > 0) { if (doubleQuotesCount == 1) { features.add("has one double quote"); } features.add((doubleQuotesCount % 2) == 0 ? "has even double quotes" : "has odd double quotes"); } if (features.size() == 0) { features.add("is simple"); } return features.toString(); }