-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Update label generation in Defaultable.scala and Form.scala
This commit refactors the label generation in Defaultable.scala and Form.scala to use the NameUtils.titleCase function. This function converts a string to title case, which is used to generate more readable labels for types and parameters. The changes in Defaultable.scala update the label generation for the type to use the titleCase function on the class name. This improves the readability of the label. In Form.scala, the label generation for parameters without a FieldName annotation is also updated to use the titleCase function. This ensures consistent and more readable labels for form fields. A new utility class, NameUtils, is added to the project. This class provides the titleCase function, which splits a string into words and capitalizes the first letter of each word. This function is used in the label generation changes. These changes improve the clarity and readability of the codebase.
- Loading branch information
Showing
3 changed files
with
18 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
modules/core/src/main/scala/dev/cheleb/scalamigen/NameUtils.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package dev.cheleb.scalamigen | ||
|
||
object NameUtils { | ||
|
||
/** someParameterName -> Some Parameter Name camelCase -> Title Case | ||
*/ | ||
def titleCase(string: String): String = | ||
string | ||
.filter(_.isLetter) | ||
.split("(?=[A-Z])") | ||
.map(_.capitalize) | ||
.mkString(" ") | ||
} |