From fdee1249e43e5526f50e443ce790431d0eaa0b9d Mon Sep 17 00:00:00 2001 From: hmctscivil Date: Fri, 14 Apr 2023 15:02:45 +0100 Subject: [PATCH] ST-645 DynamicMultiSelectList object created --- .../ccd/sdk/type/DynamicMultiSelectList.java | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/ccd-config-generator/src/main/java/uk/gov/hmcts/ccd/sdk/type/DynamicMultiSelectList.java b/ccd-config-generator/src/main/java/uk/gov/hmcts/ccd/sdk/type/DynamicMultiSelectList.java index 0ab2b598..bf1512fb 100644 --- a/ccd-config-generator/src/main/java/uk/gov/hmcts/ccd/sdk/type/DynamicMultiSelectList.java +++ b/ccd-config-generator/src/main/java/uk/gov/hmcts/ccd/sdk/type/DynamicMultiSelectList.java @@ -1,17 +1,14 @@ package uk.gov.hmcts.ccd.sdk.type; import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; -import java.util.Optional; import java.util.UUID; import java.util.stream.Collectors; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import lombok.extern.jackson.Jacksonized; import uk.gov.hmcts.ccd.sdk.api.ComplexType; /** @@ -22,7 +19,6 @@ @Data @ComplexType(generate = false) @JsonIgnoreProperties(ignoreUnknown = true) -@Jacksonized public class DynamicMultiSelectList { /** @@ -46,6 +42,14 @@ public DynamicMultiSelectList( this.listItems = listItems; } + /** + * Converts a list of elements to the appropriate structure to then be handled correctly by CCD. + * + * @param elements elements to convert into options for the dropdown + * @param selected a {@link DynamicListElement} that will be the default selected element of the list + * @param a class that implements {@link DynamicElementIndicator#toDynamicElement()} + * @return a {@link DynamicMultiSelectList} to be sent to CCD + */ public static DynamicMultiSelectList toDynamicMultiSelectList( List elements, List selected) { @@ -54,18 +58,12 @@ public static DynamicMultiSelectList toDynam return DynamicMultiSelectList.builder().listItems(items).value(selected).build(); } - @JsonIgnore - public String getValueLabel() { - return value == null ? null : value.toString(); + public String getValueLabel(DynamicListElement element) { + return element == null ? null : element.getLabel(); } - @JsonIgnore - public UUID getValueCodeAsUuid() { - return Optional.ofNullable(getValueCode()).map(UUID::fromString).orElse(null); + public UUID getValueCode(DynamicListElement element) { + return element == null ? null : element.getCode(); } - @JsonIgnore - public String getValueCode() { - return value == null ? null : value.toString(); - } }