Interface PropertyNamingStrategy


public interface PropertyNamingStrategy

Specifies a predefined property name conversion for serialization and deserialization.

This interface serves two purposes:

All naming stategies apply to the identity property name which is determined by one of the following program elements:

  • field name
  • JavaBean property name
  • record component name
  • record virtual attribute name

A naming strategy applies globally to all serialized and deserialized types. The stategy transforms the identity property name into a JSON property name.

Interaction with other naming customizations

A JsonbProperty annotation on a field, record component, accessor method, virtual attribute, or constructor/factory-method parameter takes precedence over this strategy for that individual property. The strategy is applied to properties only when no such annotation is present.

Since:
JSON Binding 1.0
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    During serialization, the IDENTITY strategy is used; the property name is written to JSON unchanged.
    static final String
    The identity property name is used unchanged as the JSON property name.
    static final String
    The identity property name is transformed to lower case with dashes.
    static final String
    The identity property name is transformed to lower case with underscores.
    static final String
    The first character of the identity property name is capitalized; the remainder is unchanged.
    static final String
    The first character of the property name is capitalized and camel-case word boundaries are replaced with spaces.
  • Method Summary

    Modifier and Type
    Method
    Description
    translateName(String propertyName)
    Translates an identity property name into its JSON property name representation according to this strategy.
  • Field Details

    • IDENTITY

      static final String IDENTITY

      The identity property name is used unchanged as the JSON property name.

      This is the default naming stategy.

      See Also:
    • LOWER_CASE_WITH_DASHES

      static final String LOWER_CASE_WITH_DASHES

      The identity property name is transformed to lower case with dashes.

      Dashes are inserted at camel-case boundaries in the identity property name

      For example, myPropertyName becomes my-property-name.

      See Also:
    • LOWER_CASE_WITH_UNDERSCORES

      static final String LOWER_CASE_WITH_UNDERSCORES

      The identity property name is transformed to lower case with underscores.

      Underscores are inserted at camel-case boundaries in the identity property name.

      For example, myPropertyName becomes my_property_name.

      See Also:
    • UPPER_CAMEL_CASE

      static final String UPPER_CAMEL_CASE

      The first character of the identity property name is capitalized; the remainder is unchanged.

      For example, myPropertyName becomes MyPropertyName.

      See Also:
    • UPPER_CAMEL_CASE_WITH_SPACES

      static final String UPPER_CAMEL_CASE_WITH_SPACES

      The first character of the property name is capitalized and camel-case word boundaries are replaced with spaces.

      For example, myPropertyName becomes My Property Name.

      See Also:
    • CASE_INSENSITIVE

      static final String CASE_INSENSITIVE

      During serialization, the IDENTITY strategy is used; the property name is written to JSON unchanged.

      During deserialization, JSON property name matching is case-insensitive.

      For example, a JSON property named PropertyNAME will be mapped to the identity property name propertyName.

      See Also:
  • Method Details

    • translateName

      String translateName(String propertyName)

      Translates an identity property name into its JSON property name representation according to this strategy.

      The returned value is used as the JSON property name during serialization and as the expected JSON property name during deserialization, unless overridden by a JsonbProperty annotation.

      Parameters:
      propertyName - identity property name to translate.
      Returns:
      the translated JSON property name.