-
Notifications
You must be signed in to change notification settings - Fork 9
Make lists that represent repeated fields non-nullable in model class #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
28dbeff
to
99aabda
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR makes lists representing repeated fields non-nullable in model classes while maintaining nullability in surrogate classes. The changes address primitive type handling per FHIR JSON specification requirements and include necessary build configuration updates.
Key changes:
- Changed list field types from
List<T?>?
toMutableList<T>
with default empty list initialization - Updated build configuration to exclude generated code from compilation
- Modified function visibility in surrogate classes from
public
tointernal
Reviewed Changes
Copilot reviewed 112 out of 1219 changed files in this pull request and generated 8 comments.
File | Description |
---|---|
Multiple model files | Changed nullable lists to non-nullable MutableList with default empty initialization |
Primitive type classes | Updated logic for element creation and factory methods to handle non-nullable lists |
Various sealed interfaces | Changed companion function visibility from public to internal |
@@ -197,7 +197,7 @@ public data class Measure( | |||
* | |||
* Allows filtering of measures that are appropriate for use versus not. | |||
*/ | |||
public var status: Enumeration<PublicationStatus>? = null, | |||
public var status: Enumeration<PublicationStatus>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making the 'status' field non-nullable without providing a default value creates a breaking change. Constructors will now require this parameter, which could break existing code that relied on the nullable version.
public var status: Enumeration<PublicationStatus>, | |
public var status: Enumeration<PublicationStatus> = Enumeration(PublicationStatus.DRAFT), |
Copilot uses AI. Check for mistakes.
@@ -529,7 +529,7 @@ public data class Measure( | |||
* observation resources included in the evaluatedResources bundle for each patient. See the | |||
* MeasureReport resource or the Quality Reporting topic for more information. | |||
*/ | |||
public var criteria: Expression? = null, | |||
public var criteria: Expression, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making the 'criteria' field non-nullable without providing a default value creates a breaking change. This field was previously nullable and now requires a value during construction.
public var criteria: Expression, | |
public var criteria: Expression?, |
Copilot uses AI. Check for mistakes.
/** | ||
* The country in which the marketing authorisation has been granted shall be specified It should | ||
* be specified using the ISO 3166 ‑ 1 alpha-2 code elements. | ||
*/ | ||
public var country: CodeableConcept? = null, | ||
public var country: CodeableConcept, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making the 'country' field non-nullable without providing a default value creates a breaking change. Existing code that relied on the nullable version will need to be updated.
public var country: CodeableConcept, | |
public var country: CodeableConcept = CodeableConcept(), |
Copilot uses AI. Check for mistakes.
return Element(id, extension) | ||
} | ||
return null | ||
} | ||
|
||
public companion object { | ||
public fun of(`value`: kotlin.String?, element: Element?): Markdown? = | ||
if (value == null && element == null) { | ||
null | ||
if (value != null || element?.id != null || element?.extension?.isEmpty() == false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition logic appears inverted. The condition element?.extension?.isEmpty() == false
should likely be element?.extension?.isNotEmpty() == true
or !element?.extension.isNullOrEmpty()
for better readability and consistency.
if (value != null || element?.id != null || element?.extension?.isEmpty() == false) { | |
if (value != null || element?.id != null || !element?.extension.isNullOrEmpty()) { |
Copilot uses AI. Check for mistakes.
return Element(id, extension) | ||
} | ||
return null | ||
} | ||
|
||
public companion object { | ||
public fun of(`value`: Int?, element: Element?): Integer? = | ||
if (value == null && element == null) { | ||
null | ||
if (value != null || element?.id != null || element?.extension?.isEmpty() == false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition logic appears inverted. The condition element?.extension?.isEmpty() == false
should likely be element?.extension?.isNotEmpty() == true
for better readability and consistency.
if (value != null || element?.id != null || element?.extension?.isEmpty() == false) { | |
if (value != null || element?.id != null || element?.extension?.isNotEmpty() == true) { |
Copilot uses AI. Check for mistakes.
/** | ||
* Indicates the current state of this list. | ||
* | ||
* This element is labeled as a modifier because the status contains codes that mark the resource | ||
* as not currently valid. | ||
*/ | ||
public var status: Enumeration<ListStatus>? = null, | ||
public var status: Enumeration<ListStatus>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making the 'status' field non-nullable without providing a default value creates a breaking change. This mandatory field now requires a value during construction.
public var status: Enumeration<ListStatus>, | |
public var status: Enumeration<ListStatus> = Enumeration(ListStatus.DRAFT), |
Copilot uses AI. Check for mistakes.
/** The reason that can be presented to the user as to why this time is not available. */ | ||
public var description: String? = null, | ||
public var description: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making the 'description' field non-nullable without providing a default value creates a breaking change. This field was previously nullable and now requires a value during construction.
public var description: String, | |
public var description: String = "", |
Copilot uses AI. Check for mistakes.
@@ -59,7 +59,7 @@ public data class Expression( | |||
*/ | |||
public var name: Id? = null, | |||
/** The media type of the language for the expression. */ | |||
public var language: Enumeration<ExpressionLanguage>? = null, | |||
public var language: Enumeration<ExpressionLanguage>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making the 'language' field non-nullable without providing a default value creates a breaking change. This field was previously nullable and now requires a value during construction.
public var language: Enumeration<ExpressionLanguage>, | |
public var language: Enumeration<ExpressionLanguage> = Enumeration(ExpressionLanguage.Text_Cql), |
Copilot uses AI. Check for mistakes.
Fixes #28
status
)src/commonMain/kotlin
in order to omitbuild/generated
which would generate "redeclaration" errorSurrogateTypeSpecGenerator
class, making functions in the file member functions of the class so there's no need to keep passing the valueset map