private Driver buildMergedDriver(PiPipeconfId pipeconfId, String baseDriverName,
String newDriverName) {
final Driver baseDriver = getDriver(baseDriverName);
if (baseDriver == null) {
log.error("Base driver {} not found, cannot build a merged one",
baseDriverName);
return null;
}
final PiPipeconf pipeconf = pipeconfs.get(pipeconfId);
if (pipeconf == null) {
log.error("Pipeconf {} is not registered, cannot build a merged driver",
pipeconfId);
return null;
}
final Map<Class<? extends Behaviour>, Class<? extends Behaviour>> behaviours =
new HashMap<>();
pipeconf.behaviours().forEach(
b -> behaviours.put(b, pipeconf.implementation(b).get()));
final Driver piPipeconfDriver = new DefaultDriver(
newDriverName, baseDriver.parents(),
baseDriver.manufacturer(), baseDriver.hwVersion(),
baseDriver.swVersion(), behaviours, new HashMap<>());
return piPipeconfDriver.merge(baseDriver);
}