I'm starting to introduce kotlin in our project and I'm converting some entities to kotlin as part as a bigger refactor.
My entity had a boolean active property:
private boolean active = true;
public boolean isActive() {
return active;
}
public void setActive(final boolean active) {
this.active = active;
}
Now in kotlin this should be:
var isActive: Boolean = true
The problem is that this way I have to refactor existing queries, not a big deal, but I was expecting a smoother transition.
I can do something like:
var active: Boolean = true
val isActive: Boolean
get()= active
But it doesn't feel right. What would be the best way?
You can rename the getter like so
@get:JvmName("isActive")
var active: Boolean = true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With