SlotFilterBuilder { public static Predicate<SlotStatus> build(UriInfo uriInfo, boolean filterRequired, List<UUID> allUuids) { SlotFilterBuilder builder = new SlotFilterBuilder(); for (Entry<String, List<String>> entry : uriInfo.getQueryParameters().entrySet()) { if ("state".equals(entry.getKey())) { for (String stateFilter : entry.getValue()) { builder.addStateFilter(stateFilter); } } else if ("!state".equals(entry.getKey())) { for (String stateFilter : entry.getValue()) { builder.addNotStateFilter(stateFilter); } } else if ("host".equals(entry.getKey())) { for (String hostGlob : entry.getValue()) { builder.addHostGlobFilter(hostGlob); } } else if ("!host".equals(entry.getKey())) { for (String hostGlob : entry.getValue()) { builder.addNotHostGlobFilter(hostGlob); } } else if ("machine".equals(entry.getKey())) { for (String machineGlob : entry.getValue()) { builder.addMachineGlobFilter(machineGlob); } } else if ("!machine".equals(entry.getKey())) { for (String machineGlob : entry.getValue()) { builder.addNotMachineGlobFilter(machineGlob); } } else if ("uuid".equals(entry.getKey())) { for (String shortId : entry.getValue()) { builder.addSlotUuidFilter(shortId); } } else if ("!uuid".equals(entry.getKey())) { for (String shortId : entry.getValue()) { builder.addNotSlotUuidFilter(shortId); } } else if ("binary".equals(entry.getKey())) { for (String binaryGlob : entry.getValue()) { builder.addBinaryGlobFilter(binaryGlob); } } else if ("!binary".equals(entry.getKey())) { for (String binaryGlob : entry.getValue()) { builder.addNotBinaryGlobFilter(binaryGlob); } } else if ("config".equals(entry.getKey())) { for (String configGlob : entry.getValue()) { builder.addConfigGlobFilter(configGlob); } } else if ("!config".equals(entry.getKey())) { for (String configGlob : entry.getValue()) { builder.addNotConfigGlobFilter(configGlob); } } else if ("all".equals(entry.getKey())) { builder.selectAll(); } } return builder.buildPredicate(filterRequired, allUuids); } private  SlotFilterBuilder(); static SlotFilterBuilder builder(); static Predicate<SlotStatus> build(UriInfo uriInfo, boolean filterRequired, List<UUID> allUuids); SlotFilterBuilder addStateFilter(String stateFilter); SlotFilterBuilder addNotStateFilter(String notStateFilter); SlotFilterBuilder addSlotUuidFilter(String shortId); SlotFilterBuilder addNotSlotUuidFilter(String notShortId); SlotFilterBuilder addHostGlobFilter(String hostGlob); SlotFilterBuilder addNotHostGlobFilter(String notHostGlob); void addMachineGlobFilter(String machineGlob); void addNotMachineGlobFilter(String notMachineGlob); SlotFilterBuilder addBinaryGlobFilter(String binaryGlob); SlotFilterBuilder addNotBinaryGlobFilter(String notBinaryGlob); SlotFilterBuilder addConfigGlobFilter(String configGlob); SlotFilterBuilder addNotConfigGlobFilter(String notConfigGlob); SlotFilterBuilder selectAll(); Predicate<SlotStatus> buildPredicate(boolean filterRequired, final List<UUID> allUuids); URI buildUri(URI baseUri); URI buildUri(HttpUriBuilder uriBuilder);  }
@Test(expectedExceptions = InvalidSlotFilterException.class) public void testEmptyFilter() { SlotFilterBuilder.build(MockUriInfo.from("fake: }
@Test public void testAll() { assertTrue(SlotFilterBuilder.build(MockUriInfo.from("fake: assertTrue(SlotFilterBuilder.build(MockUriInfo.from("fake: assertTrue(SlotFilterBuilder.build(MockUriInfo.from("fake: }