/** * Generates an annotation from an existing annotation and DeviceConfig. * * @param cfg the device config entity from network config * @param an the annotation * @return annotation combining both sources */ public static SparseAnnotations combine(BasicDeviceConfig cfg, SparseAnnotations an) { DefaultAnnotations.Builder builder = DefaultAnnotations.builder(); builder.putAll(an); if (!Objects.equals(cfg.driver(), an.value(AnnotationKeys.DRIVER))) { builder.set(AnnotationKeys.DRIVER, cfg.driver()); } combineElementAnnotations(cfg, builder); if (cfg.managementAddress() != null) { builder.set(AnnotationKeys.MANAGEMENT_ADDRESS, cfg.managementAddress()); } return builder.build(); }