Expose `translate()` method of standard `PropertyNamingStrategy` implementations
See original GitHub issueIs your feature request related to a problem? Please describe.
I work on a REST server that uses PropertyNamingStrategies.SNAKE_CASE
to translate Java property names to JSON field names.
The application code needs to report errors to the REST client, using the translated property names, but it has only the Java names.
PropertyNamingStrategies.SNAKE_CASE
does have a translate
function that does exactly what I need, but it is declared in NamingBase
while SNAKE_CASE
is declaredas PropertyNamingStrategy
.
Describe the solution you’d like
- Declare
public translate(String)
inPropertyNamingStrategy
, or - Declare
PropertyNamingStrategy SNAKE_CASE
asNamingBase
orSnakeCaseStrategy
.
Usage example
Current application code:
import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy;
...
private static SnakeCaseStrategy toSnakeCaseConverter = new SnakeCaseStrategy();
...
propertyName = toSnakeCaseConverter.translate(propertyName);
Application code after change:
import static com.fasterxml.jackson.databind.PropertyNamingStrategies.SNAKE_CASE;
...
propertyName = toSnakeCaseConverter.translate(propertyName);
Issue Analytics
- State:
- Created a year ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
PropertyNamingStrategy (jackson-databind 2.7.0 API)
Class that defines how names of JSON properties ("external names") are derived from names of POJO methods and fields ("internal names"), in cases...
Read more >PropertyNamingStrategy (The Adobe AEM Quickstart and Web ...
Default (empty) implementation returns suggested ("default") name unmodified. Note that the strategy is guaranteed to be called once per logical property ...
Read more >SpringBoot 配置文件application.properties - wade&luffy - 博客园
expose -session-attributes=false # Set whether all HttpSession attributes should be added to the model prior to merging with the template. spring ...
Read more >Index (jackson-databind 2.9.10.1 API) - Javadoc.io
actualType() - Method in class com.fasterxml.jackson.databind.type. ... Standard implementation used by ObjectMapper : adds methods only exposed to ...
Read more >Spring Boot Reference Guide
Exposing YAML as properties in the Spring Environment; 23.6.3. ... You can use Spring Boot in the same way as any standard Java...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I should be able to check on Monday. Code review already happened, nothing I could see.
Yup, no auto-formatter. I tend to end up fighting more wrt indentation and never get it quite right. As to static final vs final static I forget which one is the canonical one which ends up being one or the other; compilers accept either so to me it does not greatly matter. Just should be same within single class file.
Anyway, please LMK if somehow something was missing; otherwise I assume this works like it should 😃