### Question:
SparqlThingQuery implements ThingQuery { @Override public List<Thing> filter(Collection<Thing> things) { if (things.isEmpty()) { return List.of(); } SailRepository repository = new SailRepository(new MemoryStore()); repository.init(); Map<String, Thing> resourceToThings = new HashMap<>(); for (Thing thing : things) { StringReader reader = new StringReader(thing.toJson()); try { Model model = Rio.parse(reader, DEFAULT_BASE_IRI, FORMAT); RdfResource resource = new RdfResource(model); resourceToThings.put(resource.getIri().stringValue(), thing); Repositories.consume(repository, connection -> { connection.add(resource.getMetadata()); connection.add(resource.getContent(), resource.getIri()); }); } catch (IOException e) { log.warn("Unable to create rdf resource for thing {}: {}", thing.getId(), e.getMessage()); } } Set<String> filteredIris = Repositories.tupleQuery(repository, "SELECT DISTINCT ?__id__ WHERE { GRAPH ?__id__ { " + query + " }}", result -> { Set<BindingSet> bindings = Iterations.asSet(result); return bindings.stream().map(b -> b.getValue("__id__").stringValue()).collect(Collectors.toSet()); }); List<Thing> filteredThings = filteredIris.stream() .map(resourceToThings::get).collect(Collectors.toList()); repository.shutDown(); return filteredThings; } SparqlThingQuery(String query);   SparqlThingQuery(); @Override List<Thing> filter(Collection<Thing> things); String getQuery(); @Override int hashCode(); @Override boolean equals(Object o); @Override String toString();  }### Answer:
@Test public void filterById() throws ThingQueryException { List<Thing> things = new ArrayList<>(); things.add( new Thing.Builder() .setObjectContext(new Context("https: .setObjectType("Type") .setId("KlimabotschafterWetterstationen:Stellingen") .build() ); for (int i = 0; i < 10; i++) { things.add( new Thing.Builder() .setObjectContext(new Context("https: .setObjectType("Type").setId("luftdaten.info:" + i) .build() ); } ThingQuery query = new SparqlThingQuery("?s ?p ?o.\n" + "FILTER (STRSTARTS(STR(?s), \"KlimabotschafterWetterstationen:\"))"); Collection<Thing> filtered = query.filter(things); assertEquals(1, filtered.size()); }