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

Alias Query #172

Closed
nhojpatrick opened this issue Jun 6, 2017 · 3 comments
Closed

Alias Query #172

nhojpatrick opened this issue Jun 6, 2017 · 3 comments

Comments

@nhojpatrick
Copy link

Reading the documentation, specifically regarding @PropertyDefinition alias. Using the below example I would expect it to generate getCase and setCase methods, but generates getACase and setACase instead.

@BeanDefinition
public class AliasQuery
        implements Bean {
    @PropertyDefinition(alias = "case")
    private String aCase;
}

I've got several POJO's I would like to switch over to using Joda Beans, but because the name conflicts with a keyword the private variable is often prefixed with '_' or a and the getter and setter have slightly different names. e.g. getCase/setCase and getLong/setLong.

Am I missing something from the documentation which might aid me switching to Joda Beans without having to do a mass refactoring exercise.

@hackmann
Copy link
Contributor

hackmann commented Jun 7, 2017

You can use prefix in the generator for that.

@jodastephen
Copy link
Member

As mentioned above, the prefix command line argument (available in the Maven plugin too) allows all instance variables to have the same prefix. But you can't mix and match, with some having the prefix and others not having the prefix.

The alias concept is intended for some backwards compatibility use cases. When using methods that lookup the property by name, if the alias was used then both the alias and the actual name will resolve to the same property.

@nhojpatrick
Copy link
Author

Just looked into prefix, looks like it will do what I need. But the fact I've got variables matching java keywords, e.g. case, long and switch. It looks simpler if I manually manage those getter/setter methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants