Skip to content

Rename NamingStrategy to FieldNamingStrategy #178

Closed
@Chuckame

Description

Current issue

Now, defining a naming strategy impacts both records' and fields' name... Well it seems. It only applies the naming strategy to field names (and the fixed names as it relies on the field name).

Proposal

Have a clear FieldNamingStrategy and improve the interface:

public interface FieldNamingStrategy {
    public fun resolve(
        descriptor: SerialDescriptor,
        elementIndex: Int,
    ): String

    public companion object Builtins {
        public object NoOp : FieldNamingStrategy {
            override fun resolve(
                descriptor: SerialDescriptor,
                elementIndex: Int,
            ): String = descriptor.getElementName(elementIndex)
        }

        public object SnakeCase : FieldNamingStrategy {
                // ...
        }

        public object PascalCase : {
                // ...
        }
    }
}

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions