use of org.wildfly.swarm.spi.api.config.ConfigKey in project wildfly-swarm by wildfly-swarm.
the class InterfaceExtension method applyConfiguration.
@Override
protected void applyConfiguration(Interface instance) {
ConfigKey key = ROOT.append(instance.getName().replace("-interface", ""));
applyConfiguration(key.append("bind"), (bind) -> {
instance.setExpression(bind.toString());
});
}
use of org.wildfly.swarm.spi.api.config.ConfigKey in project wildfly-swarm by wildfly-swarm.
the class ConfigNode method recursiveChild.
/**
* Set the value of a descendant.
*
* <p>Any intermediate leafs will be created as-needed.</p>
*
* @param key The possibly-complex key to a descendant.
* @param value The value to set.
*/
public void recursiveChild(ConfigKey key, Object value) {
SimpleKey head = key.head();
if (head == ConfigKey.EMPTY) {
value(value);
}
ConfigKey rest = key.subkey(1);
if (rest == ConfigKey.EMPTY) {
child(head, value);
} else {
ConfigNode child = child(head);
if (child == null) {
child = new ConfigNode();
child(head, child);
}
child.recursiveChild(rest, value);
}
}
use of org.wildfly.swarm.spi.api.config.ConfigKey in project wildfly-swarm by wildfly-swarm.
the class ConfigNode method descendant.
ConfigNode descendant(ConfigKey key) {
SimpleKey head = key.head();
if (head == ConfigKey.EMPTY) {
return this;
}
ConfigKey rest = key.subkey(1);
ConfigNode child = child(head);
if (child == null) {
return null;
}
return child.descendant(rest);
}
use of org.wildfly.swarm.spi.api.config.ConfigKey in project wildfly-swarm by wildfly-swarm.
the class ConfigNode method allKeysRecursively.
/**
* Retrieve all descendent keys.
*
* @return A stream of all descendent keys.
*/
public Stream<ConfigKey> allKeysRecursively() {
Stream<ConfigKey> str = Stream.empty();
if (this.value != null) {
str = Stream.of(ConfigKey.EMPTY);
}
str = Stream.concat(str, this.children.entrySet().stream().flatMap((kv) -> {
ConfigKey key = kv.getKey();
Object value = kv.getValue();
if (value instanceof ConfigNode) {
return ((ConfigNode) value).allKeysRecursively().map(childKey -> key.append(childKey));
}
return Stream.empty();
}));
return str;
}
use of org.wildfly.swarm.spi.api.config.ConfigKey in project wildfly-swarm by wildfly-swarm.
the class EnvironmentConfigNodeFactory method load.
protected static void load(ConfigNode config, Map<String, String> input) {
Set<String> names = input.keySet();
for (String name : names) {
if (name.startsWith("swarm.")) {
String value = input.get(name);
ConfigKey key = ConfigKey.parse(name);
config.recursiveChild(key, value);
}
}
}
Aggregations