Skip to content

Commit 1b50133

Browse files
committed
CDPS-1054: Replaced the field name enum with a companion object to allow compile time constants.
1 parent 3700f9c commit 1b50133

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

src/main/kotlin/uk/gov/justice/digital/hmpps/personintegrationapi/corepersonrecord/dto/request/CorePersonRecordV1UpdateRequestDto.kt

+15-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo
55
import io.swagger.v3.oas.annotations.media.Schema
66
import jakarta.validation.constraints.NotNull
77
import org.springframework.format.annotation.DateTimeFormat
8-
import uk.gov.justice.digital.hmpps.personintegrationapi.corepersonrecord.enumeration.CorePersonRecordField
98
import java.time.LocalDate
109

1110
@JsonTypeInfo(
@@ -15,14 +14,20 @@ import java.time.LocalDate
1514
visible = true,
1615
)
1716
@JsonSubTypes(
18-
JsonSubTypes.Type(name = "BIRTHPLACE", value = BirthplaceUpdateDto::class),
19-
JsonSubTypes.Type(name = "COUNTRY_OF_BIRTH", value = CountryOfBirthUpdateDto::class),
20-
JsonSubTypes.Type(name = "DATE_OF_BIRTH", value = DateOfBirthUpdateDto::class),
17+
JsonSubTypes.Type(name = CorePersonRecordV1UpdateRequestDto.BIRTHPLACE, value = BirthplaceUpdateDto::class),
18+
JsonSubTypes.Type(name = CorePersonRecordV1UpdateRequestDto.COUNTRY_OF_BIRTH, value = CountryOfBirthUpdateDto::class),
19+
JsonSubTypes.Type(name = CorePersonRecordV1UpdateRequestDto.DATE_OF_BIRTH, value = DateOfBirthUpdateDto::class),
2120
)
2221
@Schema(description = "Core Person Record V1 update request base")
2322
sealed class CorePersonRecordV1UpdateRequestDto {
2423
open val fieldName: Any? = null
2524
abstract val value: Any?
25+
26+
companion object {
27+
const val BIRTHPLACE = "BIRTHPLACE"
28+
const val COUNTRY_OF_BIRTH = "COUNTRY_OF_BIRTH"
29+
const val DATE_OF_BIRTH = "DATE_OF_BIRTH"
30+
}
2631
}
2732

2833
@Schema(description = "Core Person Record V1 birthplace update request")
@@ -39,11 +44,11 @@ data class BirthplaceUpdateDto(
3944
@Schema(
4045
type = "String",
4146
description = "The field to be updated",
42-
allowableValues = ["BIRTHPLACE"],
47+
allowableValues = [BIRTHPLACE],
4348
required = true,
4449
nullable = false,
4550
)
46-
override val fieldName: CorePersonRecordField = CorePersonRecordField.BIRTHPLACE
51+
override val fieldName: String = BIRTHPLACE
4752
}
4853

4954
@Schema(description = "Core Person Record V1 date of birth update request")
@@ -61,11 +66,11 @@ data class DateOfBirthUpdateDto(
6166
@Schema(
6267
type = "String",
6368
description = "The field to be updated",
64-
allowableValues = ["DATE_OF_BIRTH"],
69+
allowableValues = [DATE_OF_BIRTH],
6570
required = true,
6671
nullable = false,
6772
)
68-
override val fieldName: CorePersonRecordField = CorePersonRecordField.DATE_OF_BIRTH
73+
override val fieldName: String = DATE_OF_BIRTH
6974
}
7075

7176
@Schema(description = "Core Person Record V1 country of birth update request")
@@ -82,9 +87,9 @@ data class CountryOfBirthUpdateDto(
8287
@Schema(
8388
type = "String",
8489
description = "The field to be updated",
85-
allowableValues = ["COUNTRY_OF_BIRTH"],
90+
allowableValues = [COUNTRY_OF_BIRTH],
8691
required = true,
8792
nullable = false,
8893
)
89-
override val fieldName: CorePersonRecordField = CorePersonRecordField.COUNTRY_OF_BIRTH
94+
override val fieldName: String = COUNTRY_OF_BIRTH
9095
}

src/main/kotlin/uk/gov/justice/digital/hmpps/personintegrationapi/corepersonrecord/enumeration/CorePersonRecordField.kt

-7
This file was deleted.

0 commit comments

Comments
 (0)