Hi everyone, I wrote a simple annotation processor...
# announcements
t
Hi everyone, I wrote a simple annotation processor for generating equals methods that ignore specified field names. In case anyone finds this useful, it's here: https://github.com/tomtau/kotlin-equals-ignoring-fields
d
If you move the fields out of the constructor they are ignored in the auto generated methods
ah, I just saw about the issue with arrays
t
@diego-gomez-olvera do you mean something like this
Copy code
data class Example(val y: Int) {
    var x: Int = 0
}
?
d
yes
the issue is that it does not work with arrays, something that I didn't notice because I generally don't use them for
data
classes
t
@diego-gomez-olvera can you post an issue with an example? I just tried this:
Copy code
@GenEqualsIgnore(
    [EqualsIgnore(["id"]),
    EqualsIgnore(["outsideConstructor"])]
)
data class Test(val id: Long, val date: Long, val count: Int, val test: ByteArray) {
    var outsideConstructor = 1
}
These are the generated methods:
Copy code
fun Test.equalsIgnore_id(other: Test): Boolean {
    if (this === other) return true
    if (this.outsideConstructor != other.outsideConstructor) return false
    if (this.date != other.date) return false
    if (this.count != other.count) return false
    if (!Arrays.equals(this.test, other.test)) return false
    return true
}

fun Test.equalsIgnore_outsideConstructor(other: Test): Boolean {
    if (this === other) return true
    if (this.id != other.id) return false
    if (this.date != other.date) return false
    if (this.count != other.count) return false
    if (!Arrays.equals(this.test, other.test)) return false
    return true
}
looks ok to me, but maybe I missed something?
d
no, indeed your solution is correct. I might have express myself incorrectly, the issue with arrays happen with https://kotlinlang.slack.com/archives/C0922A726/p1527125290000142?thread_ts=1527069158.000395&cid=C0922A726
there is an Intellij inspection for that