in src/main/java/org/apache/sling/feature/io/json/FeatureJSONReader.java [583:611]
private void readRequirements(final JsonObject json, final List<MatchingRequirement> container)
throws IOException {
if ( json.containsKey(JSONConstants.FEATURE_REQUIREMENTS)) {
for(final JsonValue req : checkTypeArray(JSONConstants.FEATURE_REQUIREMENTS, json.get(JSONConstants.FEATURE_REQUIREMENTS))) {
final JsonObject obj = checkTypeObject("Requirement", req);
if ( !obj.containsKey(JSONConstants.REQCAP_NAMESPACE) ) {
throw new IOException(this.exceptionPrefix.concat("Namespace is missing for requirement"));
}
final String namespace = checkTypeString("Requirement namespace", obj.get(JSONConstants.REQCAP_NAMESPACE));
Map<String, Object> attrMap = new HashMap<>();
if ( obj.containsKey(JSONConstants.REQCAP_ATTRIBUTES) ) {
final JsonObject attrs = checkTypeObject("Requirement attributes", obj.get(JSONConstants.REQCAP_ATTRIBUTES));
attrs.forEach(rethrowBiConsumer((key, value) -> ManifestUtils.unmarshalAttribute(key, value, attrMap::put)));
}
Map<String, String> dirMap = new HashMap<>();
if ( obj.containsKey(JSONConstants.REQCAP_DIRECTIVES) ) {
final JsonObject dirs = checkTypeObject("Requirement directives", obj.get(JSONConstants.REQCAP_DIRECTIVES));
dirs.forEach(rethrowBiConsumer((key, value) -> ManifestUtils.unmarshalDirective(key, value, dirMap::put)));
}
final MatchingRequirement r = new MatchingRequirementImpl(null,
namespace, dirMap, attrMap);
container.add(r);
}
}
}