The NameMapper object provides a set of predefined strategies for transforming string names into common naming conventions, such as snake_case, camelCase, PascalCase, and kebab-case. Additionally, it allows for custom transformations via the Custom case class.
This object defines several NameMapper implementations:
SnakeCase: Transforms strings to snake_case (e.g., "exampleName" → "example_name").CamelCase: Transforms strings to camelCase (e.g., "example_name" → "exampleName").PascalCase: Transforms strings to PascalCase (e.g., "example_name" → "ExampleName").KebabCase: Transforms strings to kebab-case (e.g., "exampleName" → "example-name").Identity: Returns the input string as-is, performing no transformation.Custom: Allows for user-defined transformations by applying a given function to the input string.
Attributes
- Companion
- trait
- Source
- NameMapper.scala
- Graph
-
- Supertypes
- Self type
-
NameMapper.type
Members list
Type members
Classlikes
A NameMapper implementation that transforms a string into camelCase format.
A NameMapper implementation that transforms a string into camelCase format.
This object overrides the apply method to enforce the camelCase convention on the input string, while leaving the rest of the characters unmodified, except for case adjustments as required by the camelCase format.
The transformation is applied using an internal implementation that ensures the following:
- Underscores (
_) and dashes (-) are treated as delimiters and are removed. - The character immediately following a delimiter is converted to uppercase.
- The first character is always converted to lowercase unless the input string already conforms to camelCase.
Attributes
- Source
- NameMapper.scala
- Supertypes
-
trait Singletontrait Producttrait Mirrortrait Serializabletrait Producttrait Equalstrait NameMappertrait String => Stringclass Objecttrait Matchableclass AnyShow all
- Self type
-
CamelCase.type
A case class that provides a custom implementation of the NameMapper trait.
A case class that provides a custom implementation of the NameMapper trait.
The Custom class allows for the transformation of strings (typically member names) using a user-defined function. This transformation logic is encapsulated in the function f provided at instantiation.
Value parameters
- f
-
A function that defines how to transform a string. The function takes a string (e.g., a member name) as input and returns the transformed string as output.
Attributes
- Source
- NameMapper.scala
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NameMappertrait String => Stringclass Objecttrait Matchableclass AnyShow all
An implementation of the NameMapper trait that performs no transformation on the provided member name. The identity operation is applied, where the input string is returned unchanged.
An implementation of the NameMapper trait that performs no transformation on the provided member name. The identity operation is applied, where the input string is returned unchanged.
It is a default implementation of the NameMapper trait, which can be used in the JSON codec derivation.
Also, this is useful in cases where there is a need to override field or case names during custom codec derivation to be different from the top-level one (e.g., when using a custom codec for a nested case class).
Attributes
- Source
- NameMapper.scala
- Supertypes
-
trait Singletontrait Producttrait Mirrortrait Serializabletrait Producttrait Equalstrait NameMappertrait String => Stringclass Objecttrait Matchableclass AnyShow all
- Self type
-
Identity.type
A NameMapper implementation that converts member names to kebab-case.
A NameMapper implementation that converts member names to kebab-case.
By overriding the apply method, this object enforces a kebab-case naming convention for input strings. It uses a helper function to normalize the member name, replacing uppercase letters or existing separators with lowercase letters and a hyphen (-) as the separator.
Attributes
- Source
- NameMapper.scala
- Supertypes
-
trait Singletontrait Producttrait Mirrortrait Serializabletrait Producttrait Equalstrait NameMappertrait String => Stringclass Objecttrait Matchableclass AnyShow all
- Self type
-
KebabCase.type
A NameMapper implementation that converts string names to PascalCase. PascalCase is a naming convention where each word starts with an uppercase letter and is concatenated without any separators.
A NameMapper implementation that converts string names to PascalCase. PascalCase is a naming convention where each word starts with an uppercase letter and is concatenated without any separators.
Attributes
- Source
- NameMapper.scala
- Supertypes
-
trait Singletontrait Producttrait Mirrortrait Serializabletrait Producttrait Equalstrait NameMappertrait String => Stringclass Objecttrait Matchableclass AnyShow all
- Self type
-
PascalCase.type
A predefined implementation of the NameMapper trait that converts a given string into snake_case format by replacing transitions between uppercase and lowercase letters with underscores (_) and converting all characters to lowercase.
A predefined implementation of the NameMapper trait that converts a given string into snake_case format by replacing transitions between uppercase and lowercase letters with underscores (_) and converting all characters to lowercase.
For example, "memberName" would be transformed into "member_name".
Attributes
- Source
- NameMapper.scala
- Supertypes
-
trait Singletontrait Producttrait Mirrortrait Serializabletrait Producttrait Equalstrait NameMappertrait String => Stringclass Objecttrait Matchableclass AnyShow all
- Self type
-
SnakeCase.type
Inherited and Abstract types
The names of the product elements.
The name of the type.
Value members
Concrete methods
Parses a built-in naming strategy string into a NameMapper.
Parses a built-in naming strategy string into a NameMapper.
Accepted values are identity, snake_case, camelCase, kebab-case, and PascalCase.
Attributes
- Throws
-
java.lang.IllegalArgumentException
if the provided strategy name does not match one of the supported built-in strategies.
- Source
- NameMapper.scala