SqlUtils { public static String getDimensionWhereClause(Multimap<String, String> dimensionValues) { List<String> components = new ArrayList<>(); for (Map.Entry<String, Collection<String>> entry : dimensionValues.asMap().entrySet()) { if (entry.getValue().size() == 1 && "!".equals(entry.getValue().iterator().next())) { continue; } List<String> equals = new ArrayList<>(entry.getValue().size()); for (String value : entry.getValue()) { equals.add(EQUALS.join(entry.getKey(), String.format("'%s'", value))); } components.add(OR.join(equals)); } if (components.isEmpty()) { return null; } return AND.join(components); }  static String getSql(String metricFunction,
                              String collection,
                              DateTime start,
                              DateTime end,
                              Map<String, String> dimensionValues); static String getSql(String metricFunction,
                              String collection,
                              DateTime start,
                              DateTime end,
                              Multimap<String, String> dimensionValues); static String getBetweenClause(DateTime start, DateTime end); static String getDimensionWhereClause(Multimap<String, String> dimensionValues); static String getDimensionGroupByClause(Multimap<String, String> dimensionValues); static String getDateString(DateTime dateTime);  }
@Test public void testGetDimensionWhereClause() { Multimap<String, String> dimensionValues = ImmutableMultimap.of( "A", "A1", "B", "B1", "C", "!"); String dimensionWhereClause = SqlUtils.getDimensionWhereClause(dimensionValues); Assert.assertEquals(dimensionWhereClause, "A = 'A1' AND B = 'B1'"); }