Files
quant-trader-service/src/main/java/com/quantai/trader/domain/TraderDataSourceManifest.java
T
2026-06-23 22:09:06 +08:00

49 lines
1.7 KiB
Java

package com.quantai.trader.domain;
import com.quantai.trader.enums.TraderErrorCode;
import java.time.Instant;
import java.util.Map;
public record TraderDataSourceManifest(
String sourceId,
String symbol,
String sourceType,
String exchange,
String granularity,
String sourcePath,
String contentHashSha256,
String schemaHashSha256,
Instant dataFrom,
Instant dataTo,
Instant minEventTime,
Instant maxEventTime,
String timezone,
Long rowCount,
Map<String, Object> missingSummary,
String qualityStatus
) {
public TraderDataSourceManifest {
missingSummary = Maps.immutable(missingSummary);
boolean hasFullHash = contentHashSha256 != null && !contentHashSha256.isBlank();
boolean hasSchemaTrace = schemaHashSha256 != null
&& !schemaHashSha256.isBlank()
&& rowCount != null
&& minEventTime != null
&& maxEventTime != null;
if (sourceId == null || sourceId.isBlank() || sourcePath == null || sourcePath.isBlank()) {
throw new TraderException(TraderErrorCode.TRADER_DATA_SOURCE_MISSING, "data source id and path are required");
}
if (timezone == null || timezone.isBlank()) {
throw new TraderException(TraderErrorCode.TRADER_DATA_SOURCE_MISSING, "data source timezone is required");
}
if (!hasFullHash && !hasSchemaTrace) {
throw new TraderException(
TraderErrorCode.TRADER_DATA_SOURCE_MISSING,
"data source requires content hash or schema/row/time lineage"
);
}
}
}