/** * Changes feature identifier (<code>name[/version]</code>) into a requirement specification. * The OSGi manifest header for a feature will be: <code>osgi.identity;osgi.identity=feature-name;type=karaf.feature[;version=feature-version];filter:=filter-from-attrs</code>. * * @param feature The feature name. * @return The feature requirement. */ public static String toFeatureRequirement(String feature) { String[] parts = feature.split("/"); Map<String, Object> attrs = new StringArrayMap<>(parts.length > 1 ? 3 : 2); attrs.put(IDENTITY_NAMESPACE, parts[0]); attrs.put(CAPABILITY_TYPE_ATTRIBUTE, TYPE_FEATURE); if (parts.length > 1) { attrs.put(CAPABILITY_VERSION_ATTRIBUTE, new VersionRange(parts[1])); } Map<String, String> dirs = Collections.singletonMap( Constants.FILTER_DIRECTIVE, SimpleFilter.convert(attrs).toString()); return new RequirementImpl(null, IDENTITY_NAMESPACE, dirs, attrs).toString(); }