com.yahoo.vespa.model.builder.xml.dom.chains.DependenciesBuilder Maven / Gradle / Ivy
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.builder.xml.dom.chains;
import com.yahoo.component.chain.dependencies.Dependencies;
import com.yahoo.config.model.builder.xml.XmlHelper;
import org.w3c.dom.Element;
import java.util.HashSet;
import java.util.Set;
/**
* Builds Dependencies (provides, before, after) from an element.
* @author Tony Vaagenes
*/
public class DependenciesBuilder {
private final Dependencies dependencies;
public DependenciesBuilder(Element spec) {
Set provides = read(spec, "provides");
Set before = read(spec, "before");
Set after = read(spec, "after");
dependencies = new Dependencies(provides, before, after);
}
public Dependencies build() {
return dependencies;
}
private Set read(Element spec, String name) {
Set symbols = new HashSet<>();
symbols.addAll(XmlHelper.valuesFromElements(spec, name));
symbols.addAll(XmlHelper.spaceSeparatedSymbolsFromAttribute(spec, name));
return symbols;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy