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

Customizable enum mapping (similar to Jackson’s @JsonValue) #1558

Closed
maffe opened this issue Jul 15, 2019 · 4 comments
Closed

Customizable enum mapping (similar to Jackson’s @JsonValue) #1558

maffe opened this issue Jul 15, 2019 · 4 comments
Labels

Comments

@maffe
Copy link
Contributor

maffe commented Jul 15, 2019

My database stores values I’d like to map to enum, however they differ slightly from the enum name()s. Currently I have to write a ColumnMapper to map them correctly. It would be nice to use annotations instead.

Example:
Database contains values CREATE and UPD
Java enum consists of CREATE and UPDATE

Suggestion: Provide annotations handled by the default enum mappers. For example, the enum could look like this:

enum Action {
  CREATE,
  @DatabaseValue("UPD")
  UPDATE
}

This is similar to Jackson which provides @JsonValue to map enums from and to JSON.

@leaumar
Copy link

leaumar commented Jul 15, 2019

I'm gonna assume you would have this take effect only when your EnumStrategy is BY_NAME?

@leaumar
Copy link

leaumar commented Jul 15, 2019

I'm neutral on adding this as a feature... Could give it a quick go if someone else feels this would be added value.

@leaumar
Copy link

leaumar commented Jul 15, 2019

You could always PR it with some tests by the way :) Might convince more people.

@maffe
Copy link
Contributor Author

maffe commented Jul 23, 2019

Pull request: #1561

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

No branches or pull requests

2 participants