@Test public void testParseRequireCapability() { List<Requirement> actual = RequirementParser.parseRequireCapability("osgi.extender; filter:=\"(&(osgi.extender=osgi.ds)(version>=1.0))\"; effective:=active, osgi.service; filter:=\"(objectClass=org.example.Foo)\""); assertEquals(2, actual.size()); assertEquals("(&(osgi.extender=osgi.ds)(version>=1.0))", actual.get(0).getDirectives().get("filter")); assertEquals("active", actual.get(0).getDirectives().get("effective")); }
static List<Requirement> parseRequireCapability(String header) throws IllegalArgumentException { if (header == null) { return Collections.emptyList(); } Clause[] clauses = Parser.parseHeader(header); List<Requirement> reqs = new ArrayList<>(clauses.length); for (Clause clause : clauses) { String namespace = clause.getName(); RequirementBuilderImpl reqBuilder = new RequirementBuilderImpl(namespace); for (Attribute attrib : clause.getAttributes()) { reqBuilder.addAttribute(attrib.getName(), attrib.getValue()); } for (Directive directive : clause.getDirectives()) { reqBuilder.addDirective(directive.getName(), directive.getValue()); } reqs.add(reqBuilder.build()); } return reqs; }
RequirementParser { static List<Requirement> parseRequireCapability(String header) throws IllegalArgumentException { if (header == null) { return Collections.emptyList(); } Clause[] clauses = Parser.parseHeader(header); List<Requirement> reqs = new ArrayList<>(clauses.length); for (Clause clause : clauses) { String namespace = clause.getName(); RequirementBuilderImpl reqBuilder = new RequirementBuilderImpl(namespace); for (Attribute attrib : clause.getAttributes()) { reqBuilder.addAttribute(attrib.getName(), attrib.getValue()); } for (Directive directive : clause.getDirectives()) { reqBuilder.addDirective(directive.getName(), directive.getValue()); } reqs.add(reqBuilder.build()); } return reqs; } }
RequirementParser { static List<Requirement> parseRequireCapability(String header) throws IllegalArgumentException { if (header == null) { return Collections.emptyList(); } Clause[] clauses = Parser.parseHeader(header); List<Requirement> reqs = new ArrayList<>(clauses.length); for (Clause clause : clauses) { String namespace = clause.getName(); RequirementBuilderImpl reqBuilder = new RequirementBuilderImpl(namespace); for (Attribute attrib : clause.getAttributes()) { reqBuilder.addAttribute(attrib.getName(), attrib.getValue()); } for (Directive directive : clause.getDirectives()) { reqBuilder.addDirective(directive.getName(), directive.getValue()); } reqs.add(reqBuilder.build()); } return reqs; }  }
RequirementParser { static List<Requirement> parseRequireCapability(String header) throws IllegalArgumentException { if (header == null) { return Collections.emptyList(); } Clause[] clauses = Parser.parseHeader(header); List<Requirement> reqs = new ArrayList<>(clauses.length); for (Clause clause : clauses) { String namespace = clause.getName(); RequirementBuilderImpl reqBuilder = new RequirementBuilderImpl(namespace); for (Attribute attrib : clause.getAttributes()) { reqBuilder.addAttribute(attrib.getName(), attrib.getValue()); } for (Directive directive : clause.getDirectives()) { reqBuilder.addDirective(directive.getName(), directive.getValue()); } reqs.add(reqBuilder.build()); } return reqs; }   }
RequirementParser { static List<Requirement> parseRequireCapability(String header) throws IllegalArgumentException { if (header == null) { return Collections.emptyList(); } Clause[] clauses = Parser.parseHeader(header); List<Requirement> reqs = new ArrayList<>(clauses.length); for (Clause clause : clauses) { String namespace = clause.getName(); RequirementBuilderImpl reqBuilder = new RequirementBuilderImpl(namespace); for (Attribute attrib : clause.getAttributes()) { reqBuilder.addAttribute(attrib.getName(), attrib.getValue()); } for (Directive directive : clause.getDirectives()) { reqBuilder.addDirective(directive.getName(), directive.getValue()); } reqs.add(reqBuilder.build()); } return reqs; }    }