-
Notifications
You must be signed in to change notification settings - Fork 124
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
Convert the model
module to Kotlin
#1465
Conversation
…ctory, ModelInfoReaderProvider
Formatting check succeeded! |
@@ -33,7 +33,7 @@ open class Model(val modelInfo: ModelInfo, modelManager: ModelManager?) { | |||
|
|||
for (t in index.values) { | |||
if (t is ClassType && t.label != null) { | |||
classIndex[casify(t.label)] = t | |||
classIndex[casify(t.label!!)] = t |
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.
Are we sure we want to throw an NPE here or anywhere else in this PR we use !! ?
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.
Ideally, no. I've been fixing the cases of these where it's reasonably straight forward to do so. In this case, the label
property is mutable, meaning that it could change values between the null check (t.label != null
) and the usage (t.label!!
) if, for instance, the Model was shared between different threads. I looked at changing label
to be immutable, but it requires a re-work of how the ClassTypes
are initialized. I just decided it was a bigger change than I wanted do. I've mostly kept the APIs and usages of the classes the same, only grabbing low-hanging fruit.
...r/src/test/java/org/cqframework/cql/elm/requirements/fhir/DataRequirementsProcessorTest.java
Outdated
Show resolved
Hide resolved
|
||
override fun isInstantiable(callType: DataType, context: InstantiationContext): Boolean { | ||
return if (callType is ClassType && callType.elements.size == elements.size) { | ||
sortedElements.zip(callType.sortedElements).all { (thisElement, thatElement) -> |
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.
We really need zip in Java
Quality Gate failedFailed conditions |
throw RuntimeException( | ||
java.lang.String.join( | ||
" ", | ||
"Multiple ModelInfoReaderProviders found on the classpath.", |
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.
Does Kotlin have multi-line Strings?
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.
Yes. I’ve not tried them though. I’ll give the a shot.
No description provided.