ResourceSet extends LinkedList<Resource> implements JsonSerializable { public ResourceSet filterByName(String name) { ResourceSet result = new ResourceSet(); for (Resource r : this) { if (r.getResourceId().getName().equals(name)) { result.add(r); } } return result; } ResourceSet(Collection<Resource> resources);  ResourceSet(); ResourceSet filterByNameRegex(String regex); ResourceSet filterByName(String name); ResourceSet filterByClassnameRegex(String regex); ResourceSet filterByClassname(String className); ResourceSet filterByNoteId(String noteId); ResourceSet filterByParagraphId(String paragraphId); String toJson(); static ResourceSet fromJson(String json);  }
@Test public void testFilterByName() { ResourceSet set = new ResourceSet(); set.add(new Resource(null, new ResourceId("poo1", "resource1"), "value1")); set.add(new Resource(null, new ResourceId("poo1", "resource2"), new Integer(2))); assertEquals(2, set.filterByNameRegex(".*").size()); assertEquals(1, set.filterByNameRegex("resource1").size()); assertEquals(1, set.filterByNameRegex("resource2").size()); assertEquals(0, set.filterByNameRegex("res").size()); assertEquals(2, set.filterByNameRegex("res.*").size()); }