Skip to content

Commit ff0f309

Browse files
committed
More warning cleanup
1 parent 905fc9b commit ff0f309

File tree

12 files changed

+42
-152
lines changed

12 files changed

+42
-152
lines changed

Src/java/engine-fhir/src/main/kotlin/org/opencds/cqf/cql/engine/fhir/converter/BaseFhirTypeConverter.kt

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ internal abstract class BaseFhirTypeConverter : FhirTypeConverter {
6363
return value as IBase
6464
}
6565

66-
require(isCqlType(value)) {
67-
String.format("can't convert %s to FHIR type", value.javaClass.getName())
68-
}
66+
require(isCqlType(value)) { "can't convert ${value.javaClass.name} to FHIR type" }
6967

7068
when (value.javaClass.getSimpleName()) {
7169
"Boolean" -> return toFhirBoolean(value as Boolean)
@@ -227,9 +225,7 @@ internal abstract class BaseFhirTypeConverter : FhirTypeConverter {
227225
return value
228226
}
229227

230-
require(isFhirType(value)) {
231-
String.format("can't convert %s to CQL type", value.javaClass.getName())
232-
}
228+
require(isFhirType(value)) { "can't convert ${value.javaClass.name} to CQL type" }
233229

234230
when (value.javaClass.getSimpleName()) {
235231
"IdType" -> return toCqlId(value as IIdType)
@@ -250,7 +246,7 @@ internal abstract class BaseFhirTypeConverter : FhirTypeConverter {
250246
"Range" -> return toCqlInterval(value as ICompositeType)
251247
else ->
252248
throw IllegalArgumentException(
253-
String.format("missing case statement for: %s", value.javaClass.getName())
249+
"missing case statement for: ${value.javaClass.name}"
254250
)
255251
}
256252
}
@@ -346,10 +342,7 @@ internal abstract class BaseFhirTypeConverter : FhirTypeConverter {
346342
calendar.get(Calendar.MILLISECOND),
347343
)
348344

349-
else ->
350-
throw InvalidPrecision(
351-
String.format("Invalid temporal precision %s", calendarConstant)
352-
)
345+
else -> throw InvalidPrecision("Invalid temporal precision $calendarConstant")
353346
}
354347
}
355348

@@ -420,10 +413,7 @@ internal abstract class BaseFhirTypeConverter : FhirTypeConverter {
420413
calendar.get(Calendar.MILLISECOND),
421414
)
422415

423-
else ->
424-
throw InvalidPrecision(
425-
String.format("Invalid temporal precision %s", calendarConstant)
426-
)
416+
else -> throw InvalidPrecision("Invalid temporal precision $calendarConstant")
427417
}
428418
}
429419

@@ -439,10 +429,7 @@ internal abstract class BaseFhirTypeConverter : FhirTypeConverter {
439429
calendar.get(Calendar.DAY_OF_MONTH),
440430
)
441431

442-
else ->
443-
throw InvalidPrecision(
444-
String.format("Invalid temporal precision %s", calendarConstant)
445-
)
432+
else -> throw InvalidPrecision("Invalid temporal precision $calendarConstant")
446433
}
447434
}
448435

Src/java/engine-fhir/src/main/kotlin/org/opencds/cqf/cql/engine/fhir/model/Dstu2FhirModelResolver.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,11 +338,7 @@ open class Dstu2FhirModelResolver(fhirContext: FhirContext) :
338338

339339
if (isStrict) {
340340
throw InvalidCast(
341-
String.format(
342-
"Cannot cast a value of type %s as %s.",
343-
value.javaClass.getName(),
344-
type.getName(),
345-
)
341+
"Cannot cast a value of type ${value.javaClass.name} as ${type.name}."
346342
)
347343
}
348344

Src/java/engine-fhir/src/main/kotlin/org/opencds/cqf/cql/engine/fhir/model/Dstu3FhirModelResolver.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,7 @@ open class Dstu3FhirModelResolver(fhirContext: FhirContext) :
342342

343343
if (isStrict) {
344344
throw InvalidCast(
345-
String.format(
346-
"Cannot cast a value of type %s as %s.",
347-
value.javaClass.getName(),
348-
type.getName(),
349-
)
345+
"Cannot cast a value of type ${value.javaClass.name} as ${type.name}."
350346
)
351347
}
352348

Src/java/engine-fhir/src/main/kotlin/org/opencds/cqf/cql/engine/fhir/model/FhirModelResolver.kt

Lines changed: 13 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -269,14 +269,14 @@ abstract class FhirModelResolver<
269269
// Special case for enumerations. They are often in the "Enumerations" class.
270270
for (packageName in this.packageNames) {
271271
try {
272-
return Class.forName(String.format("%s.Enumerations$%s", packageName, typeName))
272+
return Class.forName("$packageName.Enumerations$$typeName")
273273
} catch (_: ClassNotFoundException) {}
274274
}
275275

276276
// Other Types in package.
277277
for (packageName in this.packageNames) {
278278
try {
279-
return Class.forName(String.format("%s.%s", packageName, typeName))
279+
return Class.forName("$packageName.$typeName")
280280
} catch (_: ClassNotFoundException) {}
281281
}
282282

@@ -292,11 +292,7 @@ abstract class FhirModelResolver<
292292
return Class.forName(typeName)
293293
} catch (_: ClassNotFoundException) {
294294
throw UnknownType(
295-
String.format(
296-
"Could not resolve type %s. Primary package(s) for this resolver are %s",
297-
typeName,
298-
this.packageNames.joinToString(","),
299-
)
295+
"Could not resolve type $typeName. Primary package(s) for this resolver are ${this.packageNames.joinToString(",")}"
300296
)
301297
}
302298
}
@@ -365,7 +361,7 @@ abstract class FhirModelResolver<
365361
}
366362

367363
if (child == null) {
368-
throw DataProviderException(String.format("Unable to resolve path %s.", path))
364+
throw DataProviderException("Unable to resolve path $path.")
369365
}
370366

371367
try {
@@ -385,9 +381,7 @@ abstract class FhirModelResolver<
385381
}
386382
child.mutator.setValue(base, setBaseValue(value, base))
387383
} else {
388-
throw DataProviderException(
389-
String.format("Configuration error encountered: %s", le.message)
390-
)
384+
throw DataProviderException("Configuration error encountered: ${le.message}")
391385
}
392386
}
393387
}
@@ -484,10 +478,7 @@ abstract class FhirModelResolver<
484478

485479
else ->
486480
throw UnknownType(
487-
String.format(
488-
"Unable to resolve the runtime definition for %s",
489-
base.javaClass.getName(),
490-
)
481+
"Unable to resolve the runtime definition for ${base.javaClass.name}"
491482
)
492483
}
493484
}
@@ -538,35 +529,19 @@ abstract class FhirModelResolver<
538529
return clazz.getDeclaredConstructor().newInstance()
539530
} catch (e: NoSuchMethodException) {
540531
throw UnknownType(
541-
String.format(
542-
"Could not create an instance of class %s.\nRoot cause: %s",
543-
clazz.getName(),
544-
e.message,
545-
)
532+
"Could not create an instance of class ${clazz.name}.\nRoot cause: ${e.message}"
546533
)
547534
} catch (e: InvocationTargetException) {
548535
throw UnknownType(
549-
String.format(
550-
"Could not create an instance of class %s.\nRoot cause: %s",
551-
clazz.getName(),
552-
e.message,
553-
)
536+
"Could not create an instance of class ${clazz.name}.\nRoot cause: ${e.message}"
554537
)
555538
} catch (e: InstantiationException) {
556539
throw UnknownType(
557-
String.format(
558-
"Could not create an instance of class %s.\nRoot cause: %s",
559-
clazz.getName(),
560-
e.message,
561-
)
540+
"Could not create an instance of class ${clazz.name}.\nRoot cause: ${e.message}"
562541
)
563542
} catch (e: IllegalAccessException) {
564543
throw UnknownType(
565-
String.format(
566-
"Could not create an instance of class %s.\nRoot cause: %s",
567-
clazz.getName(),
568-
e.message,
569-
)
544+
"Could not create an instance of class ${clazz.name}.\nRoot cause: ${e.message}"
570545
)
571546
}
572547
}
@@ -650,10 +625,7 @@ abstract class FhirModelResolver<
650625
calendar.get(Calendar.MILLISECOND),
651626
)
652627

653-
else ->
654-
throw InvalidPrecision(
655-
String.format("Invalid temporal precision %s", calendarConstant)
656-
)
628+
else -> throw InvalidPrecision("Invalid temporal precision $calendarConstant")
657629
}
658630
}
659631

@@ -677,10 +649,7 @@ abstract class FhirModelResolver<
677649
calendar.get(Calendar.DAY_OF_MONTH),
678650
)
679651

680-
else ->
681-
throw InvalidPrecision(
682-
String.format("Invalid temporal precision %s", calendarConstant)
683-
)
652+
else -> throw InvalidPrecision("Invalid temporal precision $calendarConstant")
684653
}
685654
}
686655

@@ -722,10 +691,7 @@ abstract class FhirModelResolver<
722691
Precision.MINUTE -> TemporalPrecisionEnum.MINUTE
723692
Precision.SECOND -> TemporalPrecisionEnum.SECOND
724693
Precision.MILLISECOND -> TemporalPrecisionEnum.MILLI
725-
else ->
726-
throw IllegalArgumentException(
727-
String.format("Unknown precision %s", precision.toString())
728-
)
694+
else -> throw IllegalArgumentException("Unknown precision $precision")
729695
}
730696
}
731697

Src/java/engine-fhir/src/main/kotlin/org/opencds/cqf/cql/engine/fhir/model/R4FhirModelResolver.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,7 @@ open class R4FhirModelResolver(fhirContext: FhirContext) :
389389

390390
if (isStrict) {
391391
throw InvalidCast(
392-
String.format(
393-
"Cannot cast a value of type %s as %s.",
394-
value.javaClass.getName(),
395-
type.getName(),
396-
)
392+
"Cannot cast a value of type ${value.javaClass.name} as ${type.name}."
397393
)
398394
}
399395

Src/java/engine-fhir/src/main/kotlin/org/opencds/cqf/cql/engine/fhir/model/R5FhirModelResolver.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,7 @@ open class R5FhirModelResolver(fhirContext: FhirContext) :
403403

404404
if (isStrict) {
405405
throw InvalidCast(
406-
String.format(
407-
"Cannot cast a value of type %s as %s.",
408-
value.javaClass.getName(),
409-
type.getName(),
410-
)
406+
"Cannot cast a value of type ${value.javaClass.name} as ${type.name}."
411407
)
412408
}
413409

Src/java/engine-fhir/src/main/kotlin/org/opencds/cqf/cql/engine/fhir/retrieve/BaseFhirQueryGenerator.kt

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,7 @@ protected constructor(
153153

154154
if (dateParam == null) {
155155
throw UnsupportedOperationException(
156-
String.format(
157-
"Could not resolve a search parameter with date type for %s.%s ",
158-
dataType,
159-
datePath,
160-
)
156+
"Could not resolve a search parameter with date type for $dataType.$datePath "
161157
)
162158
}
163159

@@ -386,11 +382,7 @@ protected constructor(
386382
for (cp in codeParams) {
387383
if (cp.value != null && cp.value!!.size > 1) {
388384
require(chunkedCodeParam == null) {
389-
String.format(
390-
"Cannot evaluate multiple chunked code filters on %s and %s",
391-
chunkedCodeParam!!.key,
392-
cp.key,
393-
)
385+
"Cannot evaluate multiple chunked code filters on ${chunkedCodeParam!!.key} and ${cp.key}"
394386
}
395387
chunkedCodeParam = cp
396388
}

Src/java/engine-fhir/src/main/kotlin/org/opencds/cqf/cql/engine/fhir/retrieve/FhirBundleCursor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ constructor(
4242
if (
4343
this.templateId != null &&
4444
this.templateId!!.startsWith(
45-
String.format("http://hl7.org/fhir/StructureDefinition/%s", dataType)
45+
"http://hl7.org/fhir/StructureDefinition/$dataType"
4646
)
4747
) {
4848
this.templateId = null

Src/java/engine-fhir/src/main/kotlin/org/opencds/cqf/cql/engine/fhir/retrieve/FhirQueryGeneratorFactory.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ object FhirQueryGeneratorFactory {
3131
}
3232
else -> {
3333
throw IllegalArgumentException(
34-
String.format(
35-
"Unsupported FHIR version for FHIR Query Generation: %s",
36-
fhirVersionEnum,
37-
)
34+
"Unsupported FHIR version for FHIR Query Generation: $fhirVersionEnum"
3835
)
3936
}
4037
}

Src/java/engine-fhir/src/main/kotlin/org/opencds/cqf/cql/engine/fhir/retrieve/RestFhirRetrieveProvider.kt

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -109,40 +109,26 @@ class RestFhirRetrieveProvider(
109109

110110
private fun queryById(dataType: String?, map: SearchParameterMap): IBaseResource? {
111111
require(map.entrySet().size <= 1) {
112-
String.format(
113-
"Error querying %s. Queries by id must not have any other search criteria.",
114-
dataType,
115-
)
112+
"Error querying $dataType. Queries by id must not have any other search criteria."
116113
}
117114

118115
val tokenList: MutableList<IQueryParameterType> = map.get("_id")!![0]
119116
require(!tokenList.isEmpty()) {
120-
String.format(
121-
"Error querying %s. Attempted query by id but no id was specified.",
122-
dataType,
123-
)
117+
"Error querying $dataType. Attempted query by id but no id was specified."
124118
}
125119

126120
require(tokenList.size <= 1) {
127-
String.format(
128-
"Error querying %s. Attempted query by id but multiple ids were specified.",
129-
dataType,
130-
)
121+
"Error querying $dataType. Attempted query by id but multiple ids were specified."
131122
}
132123

133124
val param = tokenList[0]
134125
require(param is TokenParam) {
135-
String.format(
136-
"Error querying %s. Attempted query by id but a non-token parameter was given.",
137-
dataType,
138-
)
126+
"Error querying $dataType. Attempted query by id but a non-token parameter was given."
139127
}
140128

141129
val id = param.value
142130

143-
requireNotNull(id) {
144-
String.format("Error querying %s. Attempted query by id but id was null.", dataType)
145-
}
131+
requireNotNull(id) { "Error querying $dataType. Attempted query by id but id was null." }
146132

147133
return queryById(dataType, id)
148134
}

0 commit comments

Comments
 (0)