@Test public void makePredicateValidEntry() throws Exception { List<QueryPart> query = new ArrayList<>(); query.add(new QueryPart("Vorname", "*Sheldon")); query.add(new QueryPart("Vorname", "Sheldon")); query.add(new QueryPart("Vorname", "Sheldon*")); Predicate<Dataset> pred = DatasetPredicate.makePredicate(query); Map<String, String> testMap = new HashMap<>(); testMap.put("Vorname", "Sheldon"); Dataset ds = new SimpleDataset("Test", testMap); boolean result = pred.test(ds); assertTrue(result, "Given dataset does not match with a given QueryPart:"); }
public static Predicate<Dataset> makePredicate(List<QueryPart> query) { return query.stream().map(part -> { @SuppressWarnings("squid:S1488") Predicate<Dataset> pred = (Dataset ds) -> { try { return Pattern.matches(part.getSearchString().replaceAll("\\*", ""), ds.get(part.getColumnName())); } catch (ColumnNotFoundException ex) { return false; } }; return pred; }).reduce(matchAll, Predicate::and); }
DatasetPredicate { public static Predicate<Dataset> makePredicate(List<QueryPart> query) { return query.stream().map(part -> { @SuppressWarnings("squid:S1488") Predicate<Dataset> pred = (Dataset ds) -> { try { return Pattern.matches(part.getSearchString().replaceAll("\\*", ""), ds.get(part.getColumnName())); } catch (ColumnNotFoundException ex) { return false; } }; return pred; }).reduce(matchAll, Predicate::and); } }
DatasetPredicate { public static Predicate<Dataset> makePredicate(List<QueryPart> query) { return query.stream().map(part -> { @SuppressWarnings("squid:S1488") Predicate<Dataset> pred = (Dataset ds) -> { try { return Pattern.matches(part.getSearchString().replaceAll("\\*", ""), ds.get(part.getColumnName())); } catch (ColumnNotFoundException ex) { return false; } }; return pred; }).reduce(matchAll, Predicate::and); } private  DatasetPredicate(); }
DatasetPredicate { public static Predicate<Dataset> makePredicate(List<QueryPart> query) { return query.stream().map(part -> { @SuppressWarnings("squid:S1488") Predicate<Dataset> pred = (Dataset ds) -> { try { return Pattern.matches(part.getSearchString().replaceAll("\\*", ""), ds.get(part.getColumnName())); } catch (ColumnNotFoundException ex) { return false; } }; return pred; }).reduce(matchAll, Predicate::and); } private  DatasetPredicate(); static Predicate<Dataset> makePredicate(List<QueryPart> query); }
DatasetPredicate { public static Predicate<Dataset> makePredicate(List<QueryPart> query) { return query.stream().map(part -> { @SuppressWarnings("squid:S1488") Predicate<Dataset> pred = (Dataset ds) -> { try { return Pattern.matches(part.getSearchString().replaceAll("\\*", ""), ds.get(part.getColumnName())); } catch (ColumnNotFoundException ex) { return false; } }; return pred; }).reduce(matchAll, Predicate::and); } private  DatasetPredicate(); static Predicate<Dataset> makePredicate(List<QueryPart> query); static final Predicate<Dataset> matchAll; }