Why do some Java setter methods automatically become Kotlin properties but some don't?

112 Views Asked by At

e.g. this WebSettings Java class.

It has a Java method setJavaScriptEnabled(boolean) that turns into a Kotlin property javaScriptEnabled as below, but there is also setSupportZoom(boolean) that does not turn into a Kotlin property supportZoom.

        settings.javaScriptEnabled = true
        settings.domStorageEnabled = true
        settings.setSupportZoom(false)
        settings.builtInZoomControls = false
        settings.setSupportMultipleWindows(true)
1

There are 1 best solutions below

0
On BEST ANSWER

From the documentation:

Boolean accessor methods (where the name of the getter starts with is and the name of the setter starts with set) are represented as properties which have the same name as the getter method.

And still as of Kotlin 1.2.0:

Note that, if the Java class only has a setter, it will not be visible as a property in Kotlin, because Kotlin does not support set-only properties at this time.

There is no method in the Java class of signature boolean isSupportMultipleWindows() and boolean supportMultipleWindows() does not match the property representation in Kotlin.