com.yahoo.vespa.model.container.component.DiscBindingsConfigGenerator 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.container.component;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
import static com.yahoo.container.jdisc.JdiscBindingsConfig.Handlers;
/**
* @author gjoranv
*/
public class DiscBindingsConfigGenerator {
public static Map generate(Collection extends Handler> handlers) {
Map handlerBuilders = new LinkedHashMap<>();
for (Handler handler : handlers) {
handlerBuilders.putAll(generate(handler));
}
return handlerBuilders;
}
public static Map generate(T handler) {
if (handler.getServerBindings().isEmpty() && handler.getClientBindings().isEmpty())
return Map.of();
return Map.of(handler.model.getComponentId().stringValue(),
new Handlers.Builder()
.serverBindings(toStrings(handler.getServerBindings()))
.clientBindings(toStrings(handler.getClientBindings())));
}
private static Collection toStrings(Collection bindings) {
return bindings.stream().map(BindingPattern::patternString).toList();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy