Kotlin, JPA and boolean fields

Viewed 383

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?

1 Answers
Related