Skip to content

Commit cd35587

Browse files
committed
PR fixes
1 parent 662e8a2 commit cd35587

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

annotation/src/main/kotlin/com/tobrun/datacompat/annotation/Default.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ package com.tobrun.datacompat.annotation
1111
* it should be passed here as "\"STRING_VALUE\""; if default [Int] is used, it should be passed
1212
* as "INT_VALUE".
1313
*
14-
* @param importList if default parameter requires additional imports, they should be passed here.
14+
* @param imports if default parameter requires additional imports, they should be passed here.
1515
* E.g. `listOf("android.graphics.Color")`
1616
*/
1717
@Retention(AnnotationRetention.RUNTIME)
1818
@Target(AnnotationTarget.VALUE_PARAMETER)
1919
annotation class Default(
2020
val valueAsString: String,
21-
val importList: Array<String> = []
21+
val imports: Array<String> = []
2222
)

example/src/main/kotlin/com/tobrun/data/compat/example/PersonData.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ annotation class SampleAnnotation
1515
@DataCompat
1616
@SampleAnnotation
1717
private data class PersonData(
18-
@Default("\"John\" + Date(1580897313933L).toString()", importList = ["java.util.Date"])
18+
@Default("\"John\" + Date(1580897313933L).toString()", imports = ["java.util.Date"])
1919
val name: String,
2020
val nickname: String?,
2121
@Default("42")

processor/src/main/kotlin/com/tobrun/datacompat/DataCompatProcessor.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,8 @@ class DataCompatProcessor(
224224
.firstOrNull { it.annotationType.resolve().toString() == Default::class.simpleName }
225225
?.arguments
226226
val defaultValue = defaultAnnotationsParams?.first()
227-
if ((defaultAnnotationsParams?.size ?: 0) > 1) {
228-
defaultAnnotationsParams?.get(1)?.value?.let { importList ->
229-
imports.addAll(importList as ArrayList<String>)
230-
}
227+
defaultAnnotationsParams?.getOrNull(1)?.value?.let {
228+
imports.addAll(it as ArrayList<String>)
231229
}
232230
val nullableType = property.value.copy(nullable = true)
233231
builderBuilder.addProperty(

0 commit comments

Comments
 (0)