public InputComponentConfiguration()

in aws-applicationinsights-application/src/main/java/software/amazon/applicationinsights/application/InputConfiguration/InputComponentConfiguration.java [139:248]


    public InputComponentConfiguration(
            final InputComponentConfiguration recommendedInputConfig,
            final ComponentConfiguration defaultOverwriteComponentConfiguration) {
        ConfigurationDetails defaultOverwriteConfigurationDetails =
                defaultOverwriteComponentConfiguration.getConfigurationDetails() == null ?
                        new ConfigurationDetails() : defaultOverwriteComponentConfiguration.getConfigurationDetails();

        List<AlarmMetric> defaultOverwriteAlarmMetrics = defaultOverwriteConfigurationDetails.getAlarmMetrics();
        if (defaultOverwriteAlarmMetrics != null) {
            List<InputAlarmMetric> inputAlarmMetrics = defaultOverwriteAlarmMetrics.stream()
                    .map(alarmMetric -> new InputAlarmMetric(alarmMetric))
                    .collect(Collectors.toList());
            this.alarmMetrics = inputAlarmMetrics;
        } else {
            this.alarmMetrics = recommendedInputConfig.getAlarmMetrics();
        }

        List<Log> defaultOverwriteLogs = defaultOverwriteConfigurationDetails.getLogs();
        if (defaultOverwriteLogs != null) {
            List<InputLog> inputLogs = defaultOverwriteLogs.stream()
                    .map(log -> new InputLog(log))
                    .collect(Collectors.toList());
            this.logs = inputLogs;
        } else {
            this.logs = recommendedInputConfig.getLogs();
        }

        List<WindowsEvent> defaultOverwriteWindowsEvents = defaultOverwriteConfigurationDetails.getWindowsEvents();
        if (defaultOverwriteWindowsEvents != null) {
            List<InputWindowsEvent> inputWindowsEvents = defaultOverwriteWindowsEvents.stream()
                    .map(windowsEvent -> new InputWindowsEvent(windowsEvent))
                    .collect(Collectors.toList());
            this.windowsEvents = inputWindowsEvents;
        } else {
            this.windowsEvents = recommendedInputConfig.getWindowsEvents();
        }

        List<Alarm> defaultOverwriteAlarms = defaultOverwriteConfigurationDetails.getAlarms();
        if (defaultOverwriteAlarms != null) {
            List<InputAlarm> inputAlarms = defaultOverwriteAlarms.stream()
                    .map(alarm -> new InputAlarm(alarm))
                    .collect(Collectors.toList());
            this.alarms = inputAlarms;
        } else {
            this.alarms = recommendedInputConfig.getAlarms();
        }

        Map<String, SubComponentTypeConfiguration> defaultOverwriteSubComponentTypeConfigurationsMap =
            (defaultOverwriteComponentConfiguration.getSubComponentTypeConfigurations() == null ||
                defaultOverwriteComponentConfiguration.getSubComponentTypeConfigurations().isEmpty()) ?
                Collections.emptyMap() :
                defaultOverwriteComponentConfiguration.getSubComponentTypeConfigurations().stream()
                    .collect(Collectors.toMap(SubComponentTypeConfiguration::getSubComponentType, Function.identity()));

        Map<String, InputSubComponent> recommendedSubComponentsMap =
            (recommendedInputConfig.getSubComponents() == null ||  recommendedInputConfig.getSubComponents().isEmpty()) ?
                Collections.emptyMap() :
                recommendedInputConfig.getSubComponents().stream()
                    .collect(Collectors.toMap(InputSubComponent::getSubComponentType, Function.identity()));

        List<InputSubComponent> mergedSubComponents = new ArrayList<>();

        // If sub component type not recommended but specified by customer, set it as is
        Set<String> overwriteOnlySubComponentTypes = new HashSet<>(defaultOverwriteSubComponentTypeConfigurationsMap.keySet());
        overwriteOnlySubComponentTypes.removeAll(recommendedSubComponentsMap.keySet());
        overwriteOnlySubComponentTypes.stream().forEach(componentType -> {
            mergedSubComponents.add(new InputSubComponent(defaultOverwriteSubComponentTypeConfigurationsMap.get(componentType)));
        });

        // If sub component type recommended but not overwritten by customer, set it as recommended config
        Set<String> recommendOnlySubComponentTypes = new HashSet<>(recommendedSubComponentsMap.keySet());
        recommendOnlySubComponentTypes.removeAll(defaultOverwriteSubComponentTypeConfigurationsMap.keySet());
        recommendOnlySubComponentTypes.stream().forEach(componentType -> {
            mergedSubComponents.add(recommendedSubComponentsMap.get(componentType));
        });

        // If sub component type both recommended and overwritten by customers, merge both configs
        Set<String> mergedComponentTypes = new HashSet<>(defaultOverwriteSubComponentTypeConfigurationsMap.keySet());
        mergedComponentTypes.retainAll(recommendedSubComponentsMap.keySet());
        mergedComponentTypes.stream().forEach(componentType -> {
            mergedSubComponents.add(new InputSubComponent(
                recommendedSubComponentsMap.get(componentType),
                defaultOverwriteSubComponentTypeConfigurationsMap.get(componentType)));
        });

        if (!mergedSubComponents.isEmpty()) {
            this.subComponents = mergedSubComponents;
        }

        JMXPrometheusExporter defaultOverwriteJmxPrometheusExporter = defaultOverwriteConfigurationDetails.getJMXPrometheusExporter();
        if (defaultOverwriteJmxPrometheusExporter != null) {
            this.jmxPrometheusExporter = new InputJMXPrometheusExporter(defaultOverwriteJmxPrometheusExporter);
        } else {
            this.jmxPrometheusExporter = recommendedInputConfig.getJmxPrometheusExporter();
        }

        HANAPrometheusExporter defaultOverwriteHANAPrometheusExporter = defaultOverwriteConfigurationDetails.getHANAPrometheusExporter();
        if (defaultOverwriteHANAPrometheusExporter != null) {
            this.hanaPrometheusExporter = new InputHANAPrometheusExporter(defaultOverwriteHANAPrometheusExporter);
        } else {
            this.hanaPrometheusExporter = recommendedInputConfig.getHanaPrometheusExporter();
        }

        HAClusterPrometheusExporter defaultOverwriteHAClusterPrometheusExporter = defaultOverwriteConfigurationDetails.getHAClusterPrometheusExporter();
        if (defaultOverwriteHAClusterPrometheusExporter != null) {
            this.haClusterPrometheusExporter = new InputHAClusterPrometheusExporter(defaultOverwriteHAClusterPrometheusExporter);
        } else {
            this.haClusterPrometheusExporter = recommendedInputConfig.getHaClusterPrometheusExporter();
        }
    }