avro-kotlin / avro4k

Avro format support for Kotlin
Apache License 2.0
188 stars 36 forks source link

Rename NamingStrategy to FieldNamingStrategy #178

Open Chuckame opened 5 months ago

Chuckame commented 5 months ago

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 : {
                // ...
        }
    }
}
Chuckame commented 2 months ago

Done in #182

Chuckame commented 1 month ago

open it back, waiting for a real release