kasechange-metadata

Multiplatform Kotlin library to convert strings between various case formats including Camel Case, Snake Case, Pascal Case and Kebab Case

License

License

Categories

Categories

Data Net
GroupId

GroupId

net.pearx.kasechange
ArtifactId

ArtifactId

kasechange-metadata
Last Version

Last Version

1.3.0
Release Date

Release Date

Type

Type

module
Description

Description

kasechange-metadata
Multiplatform Kotlin library to convert strings between various case formats including Camel Case, Snake Case, Pascal Case and Kebab Case
Project URL

Project URL

https://github.com/pearxteam/kasechange
Project Organization

Project Organization

PearX Team
Source Code Management

Source Code Management

https://github.com/pearxteam/kasechange

Download kasechange-metadata

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

KaseChange Maven Central Awesome Kotlin Badge

License Discord Test & Deploy | develop Test & Deploy | master

Multiplatform Kotlin library to convert strings between various case formats

Supported Case Formats

  • SCREAMING_SNAKE_CASE
  • snake_case
  • PascalCase
  • camelCase
  • TRAIN-CASE
  • kebab-case
  • UPPER SPACE CASE
  • Title Case
  • lower space case
  • UPPER.DOT.CASE
  • dot.case
  • custom one :)

Setup

  1. Add the lib to your project's dependencies:
  • Groovy (replace $kasechange_version with the version you want):
 // universal dependency for Gradle 5.3 and above
 // in case of multiplatform project, just specify the dependency for commonMain/commonTest source set
 implementation "net.pearx.kasechange:kasechange:$kasechange_version" 
 // for Gradle versions below 5.3:
 implementation "net.pearx.kasechange:kasechange-metadata:$kasechange_version" // for Common
 // or
 implementation "net.pearx.kasechange:kasechange-jvm:$kasechange_version" // for JVM
 // or
 implementation "net.pearx.kasechange:kasechange-js:$kasechange_version" // for JS
 // or
 implementation "net.pearx.kasechange:kasechange-android:$kasechange_version" // for Android
 // or
 implementation "net.pearx.kasechange:kasechange-PLATFORM_YOU_WANT:$kasechange_version" // for Native
  • Kotlin (replace $kasechangeVersion with the version you want):
 // universal dependency for Gradle 5.3 and above
 // in case of multiplatform project, just specify the dependency for commonMain/commonTest source set
 implementation("net.pearx.kasechange:kasechange:$kasechangeVersion") 
 // for Gradle versions below 5.3:
 implementation("net.pearx.kasechange:kasechange-metadata:$kasechangeVersion") // for Common
 // or
 implementation("net.pearx.kasechange:kasechange-jvm:$kasechangeVersion") // for JVM
 // or
 implementation("net.pearx.kasechange:kasechange-js:$kasechangeVersion") // for JS
 // or
 implementation("net.pearx.kasechange:kasechange-android:$kasechangeVersion") // for Android
 // or
 implementation("net.pearx.kasechange:kasechange-PLATFORM_YOU_WAN:$kasechangeVersion") // for Native
  1. Use the library and have fun!

Examples:

  • Transforming string from any case to specific one:
 "IAmAPascalCasedString123".toSnakeCase() // i_am_a_pascal_cased_string_123
 "IAmAPascalCasedString123".toCase(CaseFormat.LOWER_UNDERSCORE)  // i_am_a_pascal_cased_string_123
 "IAmAPascalCasedString123".toCase(to = CaseFormat.LOWER_UNDERSCORE, from = universalWordSplitter())  // i_am_a_pascal_cased_string_123
 "IAmAPascalCasedString123".toSnakeCase(universalWordSplitter())  // i_am_a_pascal_cased_string_123
 "IAmAPascalCasedString123".toCase(to = CaseFormat.LOWER_UNDERSCORE, from = universalWordSplitter(treatDigitsAsUppercase = false))  // i_am_a_pascal_cased_string123
 "IAmAPascalCasedString123".toSnakeCase(universalWordSplitter(treatDigitsAsUppercase = false))  // i_am_a_pascal_cased_string123
  • Transforming string from one case to another:
 "123e4567-e89b-12d3-a456-426655440000".toSnakeCase(CaseFormat.LOWER_HYPHEN) // 123e4567_e89b_12d3_a456_426655440000
 "123e4567-e89b-12d3-a456-426655440000".toCase(to = CaseFormat.LOWER_UNDERSCORE, from = CaseFormat.LOWER_HYPHEN)  // 123e4567_e89b_12d3_a456_426655440000
  • Transforming string to a custom case:
"some_string".toCase(CaseFormatterConfig(false, "..", wordCapitalize = true, firstWordCapitalize = true)) // Some..String
  • Splitting a string in any case into words:
 "XMLExtendedParser".splitToWords() // [XML, Extended, Parser]
 "XMLExtendedParser2".splitToWords(universalWordSplitter(treatDigitsAsUppercase = true)) // [XML, Extended, Parser, 2]
 "XMLExtendedParser2".splitToWords(universalWordSplitter(treatDigitsAsUppercase = false)) // [XML, Extended, Parser2]
  • Splitting a string in specific case into words:
 "s0meth1ng_in_snake_case".splitToWords(CaseFormat.LOWER_UNDERSCORE) // [s0meth1ng, in, snake, case]
net.pearx.kasechange

PearX Team

Versions

Version
1.3.0
1.2.0
1.1.0
1.0.9
1.0.8
1.0.7
1.0.6