File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
processor/src/main/kotlin/com/tobrun/datacompat Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -132,17 +132,18 @@ class DataCompatProcessor(
132
132
)
133
133
134
134
// Function equals
135
- val equalsStatementList = mutableListOf (" other is $className " )
136
- for (entry in propertyMap) {
137
- equalsStatementList.add(" && ${entry.key} == other.${entry.key} " )
138
- }
139
135
val equalsBuilder = FunSpec .builder(" equals" )
140
136
.addModifiers(KModifier .OVERRIDE )
141
137
.addParameter(" other" , ANY .copy(nullable = true ))
138
+ .addStatement(" if (this === other) return true" )
139
+ .addStatement(" if (javaClass != other?.javaClass) return false" )
140
+ .addStatement(" other as $className " )
142
141
.addStatement(
143
- equalsStatementList .joinToString(
142
+ propertyMap.keys .joinToString(
144
143
prefix = " return " ,
145
- separator = " \n\t\t "
144
+ separator = " && " ,
145
+ transform = { " $it == other.$it " },
146
+ postfix = " "
146
147
)
147
148
)
148
149
.returns(Boolean ::class )
You can’t perform that action at this time.
0 commit comments