Summary
Replace the 17-parameter buildDeploymentData method with a typed record. Introduce element name constants to eliminate hardcoded strings across all handlers.
Problem
DeploymentHandler.buildDeploymentData() has 17 positional parameters — a severe maintenance hazard where parameter order mistakes cause silent bugs.
- Two
toMap() overloads duplicate the same extraction logic (marked CPD-OFF/CPD-ON) because SDK types AiDeploymentResponseWithDetails and AiDeployment share no common interface.
- All handlers use hardcoded string keys (
"id", "deploymentUrl", "configurationId", etc.) — if an element is renamed in the CDS model, Java code silently breaks at runtime.
Plan
Part A: Element Name Constants
Create AICoreElements.java with inner classes per entity:
public final class AICoreElements {
private AICoreElements() {}
public static final class Deployment {
public static final String ID = "id";
public static final String DEPLOYMENT_URL = "deploymentUrl";
public static final String CONFIGURATION_ID = "configurationId";
public static final String CONFIGURATION_NAME = "configurationName";
public static final String EXECUTABLE_ID = "executableId";
public static final String SCENARIO_ID = "scenarioId";
public static final String STATUS = "status";
public static final String STATUS_MESSAGE = "statusMessage";
public static final String TARGET_STATUS = "targetStatus";
public static final String LAST_OPERATION = "lastOperation";
public static final String LATEST_RUNNING_CONFIGURATION_ID = "latestRunningConfigurationId";
public static final String TTL = "ttl";
public static final String CREATED_AT = "createdAt";
public static final String MODIFIED_AT = "modifiedAt";
public static final String SUBMISSION_TIME = "submissionTime";
public static final String START_TIME = "startTime";
public static final String COMPLETION_TIME = "completionTime";
public static final String RESOURCE_GROUP = "resourceGroup";
}
public static final class ResourceGroup { ... }
public static final class Configuration { ... }
}
Replace string literals in all handlers.
Part B: DeploymentHandler Record Refactor
private record DeploymentFields(
String id, String deploymentUrl, String configurationId,
String configurationName, String executableId, String scenarioId,
String status, String statusMessage, String targetStatus,
String lastOperation, String latestRunningConfigurationId,
String ttl, Object createdAt, Object modifiedAt,
Object submissionTime, Object startTime, Object completionTime) {}
private static DeploymentFields extractFields(AiDeploymentResponseWithDetails d) { ... }
private static DeploymentFields extractFields(AiDeployment d) { ... }
private static CdsData toCdsData(DeploymentFields f, String resourceGroupId) { ... }
Remove CPD-OFF/CPD-ON markers.
Files
- New:
AICoreElements.java
- Modified:
DeploymentHandler.java (major refactor)
- Modified:
ConfigurationHandler.java (replace ~10 string literals)
- Modified:
ResourceGroupHandler.java (replace ~10 string literals)
- Modified:
MockEntityHandler.java (replace ~15 string literals)
- Modified:
ActionHandler.java (replace ~3 string literals)
Rationale
Mirrors the generated *_.CDS_NAME constant pattern used in cds4j and cds-services. Eliminates the code smell of a 17-parameter method and removes the need for CPD suppression.
Summary
Replace the 17-parameter
buildDeploymentDatamethod with a typed record. Introduce element name constants to eliminate hardcoded strings across all handlers.Problem
DeploymentHandler.buildDeploymentData()has 17 positional parameters — a severe maintenance hazard where parameter order mistakes cause silent bugs.toMap()overloads duplicate the same extraction logic (marked CPD-OFF/CPD-ON) because SDK typesAiDeploymentResponseWithDetailsandAiDeploymentshare no common interface."id","deploymentUrl","configurationId", etc.) — if an element is renamed in the CDS model, Java code silently breaks at runtime.Plan
Part A: Element Name Constants
Create
AICoreElements.javawith inner classes per entity:Replace string literals in all handlers.
Part B: DeploymentHandler Record Refactor
Remove CPD-OFF/CPD-ON markers.
Files
AICoreElements.javaDeploymentHandler.java(major refactor)ConfigurationHandler.java(replace ~10 string literals)ResourceGroupHandler.java(replace ~10 string literals)MockEntityHandler.java(replace ~15 string literals)ActionHandler.java(replace ~3 string literals)Rationale
Mirrors the generated
*_.CDS_NAMEconstant pattern used incds4jandcds-services. Eliminates the code smell of a 17-parameter method and removes the need for CPD suppression.