@Test public void testParseRequireBundle() { List<Requirement> actual = RequirementParser.parseRequireBundle("foo;bundle-version=1.0.0, bar;bundle-version=\"[1.0,1.1)\", baz;bundle-version=\"[2.0,3.0)\", fnarg"); assertEquals(4, actual.size()); assertEquals("(&(osgi.wiring.bundle=foo)(bundle-version>=1.0.0))", actual.get(0).getDirectives().get("filter")); assertEquals("(&(osgi.wiring.bundle=bar)(bundle-version>=1.0.0)(!(bundle-version>=1.1.0)))", actual.get(1).getDirectives().get("filter")); assertEquals("(&(osgi.wiring.bundle=baz)(bundle-version>=2.0.0)(!(bundle-version>=3.0.0)))", actual.get(2).getDirectives().get("filter")); assertEquals("(osgi.wiring.bundle=fnarg)", actual.get(3).getDirectives().get("filter")); }
static List<Requirement> parseRequireBundle(String header) throws IllegalArgumentException { if (header == null) { return Collections.emptyList(); } Clause[] clauses = Parser.parseHeader(header); List<Requirement> requirements = new ArrayList<>(clauses.length); for (Clause requireClause : clauses) { String bsn = requireClause.getName(); String versionRangeStr = requireClause.getAttribute(org.osgi.framework.Constants.BUNDLE_VERSION_ATTRIBUTE); String filter = toBundleFilter(bsn, versionRangeStr); Requirement requirement = new RequirementBuilderImpl(BundleNamespace.BUNDLE_NAMESPACE) .addDirective(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter) .build(); requirements.add(requirement); } return requirements; }
RequirementParser { static List<Requirement> parseRequireBundle(String header) throws IllegalArgumentException { if (header == null) { return Collections.emptyList(); } Clause[] clauses = Parser.parseHeader(header); List<Requirement> requirements = new ArrayList<>(clauses.length); for (Clause requireClause : clauses) { String bsn = requireClause.getName(); String versionRangeStr = requireClause.getAttribute(org.osgi.framework.Constants.BUNDLE_VERSION_ATTRIBUTE); String filter = toBundleFilter(bsn, versionRangeStr); Requirement requirement = new RequirementBuilderImpl(BundleNamespace.BUNDLE_NAMESPACE) .addDirective(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter) .build(); requirements.add(requirement); } return requirements; } }
RequirementParser { static List<Requirement> parseRequireBundle(String header) throws IllegalArgumentException { if (header == null) { return Collections.emptyList(); } Clause[] clauses = Parser.parseHeader(header); List<Requirement> requirements = new ArrayList<>(clauses.length); for (Clause requireClause : clauses) { String bsn = requireClause.getName(); String versionRangeStr = requireClause.getAttribute(org.osgi.framework.Constants.BUNDLE_VERSION_ATTRIBUTE); String filter = toBundleFilter(bsn, versionRangeStr); Requirement requirement = new RequirementBuilderImpl(BundleNamespace.BUNDLE_NAMESPACE) .addDirective(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter) .build(); requirements.add(requirement); } return requirements; }  }
RequirementParser { static List<Requirement> parseRequireBundle(String header) throws IllegalArgumentException { if (header == null) { return Collections.emptyList(); } Clause[] clauses = Parser.parseHeader(header); List<Requirement> requirements = new ArrayList<>(clauses.length); for (Clause requireClause : clauses) { String bsn = requireClause.getName(); String versionRangeStr = requireClause.getAttribute(org.osgi.framework.Constants.BUNDLE_VERSION_ATTRIBUTE); String filter = toBundleFilter(bsn, versionRangeStr); Requirement requirement = new RequirementBuilderImpl(BundleNamespace.BUNDLE_NAMESPACE) .addDirective(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter) .build(); requirements.add(requirement); } return requirements; }   }
RequirementParser { static List<Requirement> parseRequireBundle(String header) throws IllegalArgumentException { if (header == null) { return Collections.emptyList(); } Clause[] clauses = Parser.parseHeader(header); List<Requirement> requirements = new ArrayList<>(clauses.length); for (Clause requireClause : clauses) { String bsn = requireClause.getName(); String versionRangeStr = requireClause.getAttribute(org.osgi.framework.Constants.BUNDLE_VERSION_ATTRIBUTE); String filter = toBundleFilter(bsn, versionRangeStr); Requirement requirement = new RequirementBuilderImpl(BundleNamespace.BUNDLE_NAMESPACE) .addDirective(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter) .build(); requirements.add(requirement); } return requirements; }    }