Skip to content

Expose translate() method of standard PropertyNamingStrategy implementations #3633

Closed
@toolforger

Description

@toolforger

Is 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) in PropertyNamingStrategy, or
  • Declare PropertyNamingStrategy SNAKE_CASE as NamingBase or SnakeCaseStrategy.

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions