File tree Expand file tree Collapse file tree 3 files changed +5
-7
lines changed
annotation/src/main/kotlin/com/tobrun/datacompat/annotation
example/src/main/kotlin/com/tobrun/data/compat/example
processor/src/main/kotlin/com/tobrun/datacompat Expand file tree Collapse file tree 3 files changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -11,12 +11,12 @@ package com.tobrun.datacompat.annotation
11
11
* it should be passed here as "\"STRING_VALUE\""; if default [Int] is used, it should be passed
12
12
* as "INT_VALUE".
13
13
*
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.
15
15
* E.g. `listOf("android.graphics.Color")`
16
16
*/
17
17
@Retention(AnnotationRetention .RUNTIME )
18
18
@Target(AnnotationTarget .VALUE_PARAMETER )
19
19
annotation class Default (
20
20
val valueAsString : String ,
21
- val importList : Array <String > = []
21
+ val imports : Array <String > = []
22
22
)
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ annotation class SampleAnnotation
15
15
@DataCompat
16
16
@SampleAnnotation
17
17
private data class PersonData (
18
- @Default(" \" John\" + Date(1580897313933L).toString()" , importList = [" java.util.Date" ])
18
+ @Default(" \" John\" + Date(1580897313933L).toString()" , imports = [" java.util.Date" ])
19
19
val name : String ,
20
20
val nickname : String? ,
21
21
@Default(" 42" )
Original file line number Diff line number Diff line change @@ -224,10 +224,8 @@ class DataCompatProcessor(
224
224
.firstOrNull { it.annotationType.resolve().toString() == Default ::class .simpleName }
225
225
?.arguments
226
226
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 >)
231
229
}
232
230
val nullableType = property.value.copy(nullable = true )
233
231
builderBuilder.addProperty(
You can’t perform that action at this time.
0 commit comments