package at.procon.eventhub.processing.eventprocessing.dto;

import at.procon.eventhub.processing.eventprocessing.module.RuntimeProcessingModuleResult;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;

public record RuntimeEventProcessingPartitionResultDto(
        String partitionType,
        String partitionKey,
        String resultType,
        Object result,
        Map<String, Object> metadata,
        Map<String, RuntimeProcessingModuleResult> moduleResults
) {
    public RuntimeEventProcessingPartitionResultDto {
        metadata = metadata == null ? Map.of() : Collections.unmodifiableMap(new LinkedHashMap<>(metadata));
        moduleResults = moduleResults == null ? Map.of() : Collections.unmodifiableMap(new LinkedHashMap<>(moduleResults));
    }

    public RuntimeEventProcessingPartitionResultDto(
            String partitionType,
            String partitionKey,
            String resultType,
            Object result,
            Map<String, Object> metadata
    ) {
        this(partitionType, partitionKey, resultType, result, metadata, Map.of());
    }
}
