Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve kotlin support by allowing property access #393

Merged
merged 2 commits into from
Dec 13, 2018

Conversation

fractalwrench
Copy link
Contributor

Goal

If public getters/setters are available for a Java field, then this code can be called from Kotlin using the property access syntax. This gives users the choice of using a more Kotlin-esque syntax:

config.autoCaptureSessions = false

while retaining backward compatibility with the previous interface:

config.setAutoCaptureSessions(false)

Changeset

  • A public getter and setter were added for the autoCaptureSessions, codeBundleId, and notifierType properties.
  • shouldAutoCaptureSessions() was deprecated and forward onto getAutoCaptureSessions()
  • Internal use of shouldAutoCaptureSessions() was changed to getAutoCaptureSessions() to avoid using deprecated code
  • All KotlinPropertyAccess checks were removed from the lint_baseline file, which suppresses warnings.
  • The lint_baseline file was regenerated to account for new violations added in Add binary architecture of application to payload #389, and changes in line numbers.

Tests

Ran existing unit tests + mazerunner scenarios on CI.

adds public getters/setters that will allow property access when calling from Kotlin
Copy link
Contributor

@bengourley bengourley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this seems fine.

I do have the following concern though, which I would imagine you probably weighed up…

shouldAutoCaptureSessions() communicates very clearly that calling it will give you the answer to the question "given the current configuration, should sessions be captured automatically?".

getAutoCaptureSessions() sounds more vague, like it could provide you with some class or structure which you would use to capture sessions automatically. However, because this is Java, the fact it returns a boolean helps alleviate some of that mystery but I just think this method name is less good.

Did you consider using an is* prefix, as suggested in the Java-Kotlin interop guide for boolean returning methods? I think it would have to be something like isAutoCapturingSessions in order to make sense in english though…

Aside from the slight naming, the implementation LGTM!

@fractalwrench
Copy link
Contributor Author

To summarise internal discussion, there are 4 options:

getAutoCaptureSessions, isAutoCaptureSessions, renaming the Java method to isAutoCapturingSessions and losing the property access syntax, or doing nothing.

Of these, getAutoCaptureSessions is the preferred option.

@fractalwrench fractalwrench merged commit bfd7f68 into next Dec 13, 2018
@fractalwrench fractalwrench deleted the property-access-fixes branch December 13, 2018 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants