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

Inferred property names #73

Merged
merged 2 commits into from
Oct 13, 2023
Merged

Inferred property names #73

merged 2 commits into from
Oct 13, 2023

Conversation

jwharm
Copy link
Owner

@jwharm jwharm commented Oct 13, 2023

Make the "name" parameter of the @Property annotation optional, and infer the property name from the method names.

The following example:

@Property(name="current-angle")
public double getCurrentAngle() {
    return this.angle;
}

@property(name="current-angle")
public double setCurrentAngle(double angle) {
    this.angle = angle;
}

is equivalent to:

@Property
public double getCurrentAngle() {
    return this.angle;
}

@property
public double setCurrentAngle(double angle) {
    this.angle = angle;
}

The property name will be inferred from the method name:

  • Both methods must be regular getters and setters, following the getX/setX naming pattern
  • Java-GI will strip the get/set prefix from the method name and convert the remaining part from CamelCase to kebab-case.

@jwharm jwharm merged commit 1f2af80 into main Oct 13, 2023
@jwharm jwharm deleted the inferred-property-names branch October 13, 2023 19:32
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.

1 participant