|
| 1 | +# string-notation [](https://github.com/jGleitz/string-notation/actions) [](https://maven-badges.herokuapp.com/maven-central/de.joshuagleitze/string-notation) |
| 2 | +_Convert between different string notations commonly found in programming._ |
| 3 | +Useful, for example, to build identifiers when generating code. |
| 4 | +Also includes notations to build valid Java type or member names. |
| 5 | + |
| 6 | +[API Documentation](https://jgleitz.github.io/string-notation/string-notation/de.joshuagleitze.stringnotation/) |
| 7 | + |
| 8 | +## Usage |
| 9 | +`string-notation` converts Strings from their notation into a [Word](https://jgleitz.github.io/string-notation/string-notation/de.joshuagleitze.stringnotation/-word), which is a notation-agnostic representation. |
| 10 | +[Words](https://jgleitz.github.io/string-notation/string-notation/de.joshuagleitze.stringnotation/-word) can then be transformed into Strings in a notation again. |
| 11 | + |
| 12 | +### Kotlin |
| 13 | + |
| 14 | +```kotlin |
| 15 | +import de.joshuagleitze.stringnotation.LowerCamelCase |
| 16 | +import de.joshuagleitze.stringnotation.ScreamingSnakeCase |
| 17 | +import de.joshuagleitze.stringnotation.fromNotation |
| 18 | + |
| 19 | +// myVariable -> MY_VARIABLE |
| 20 | +"myVariable".fromNotation(LowerCamelCase).toNotation(ScreamingSnakeCase) |
| 21 | +``` |
| 22 | + |
| 23 | +```kotlin |
| 24 | +import de.joshuagleitze.stringnotation.JavaTypeName |
| 25 | +import de.joshuagleitze.stringnotation.NormalWords |
| 26 | +import de.joshuagleitze.stringnotation.fromNotation |
| 27 | + |
| 28 | +// 1 Type Name 4 You! -> TypeName4You |
| 29 | +"1 Type Name 4 You!".fromNotation(NormalWords).toNotation(JavaTypeName) |
| 30 | +``` |
| 31 | + |
| 32 | + |
| 33 | +### Java |
| 34 | + |
| 35 | +```java |
| 36 | +import de.joshuagleitze.stringnotation.LowerCamelCase; |
| 37 | +import de.joshuagleitze.stringnotation.UpperCamelCase; |
| 38 | +import static de.joshuagleitze.stringnotation.StringToWord.fromNotation; |
| 39 | + |
| 40 | +// myVariable -> MY_VARIABLE |
| 41 | +fromNotation("myVariable", UpperCamelCase.INSTANCE).toNotation(LowerCamelCase.INSTANCE); |
| 42 | +``` |
| 43 | + |
| 44 | +```java |
| 45 | +import de.joshuagleitze.stringnotation.JavaTypeName; |
| 46 | +import de.joshuagleitze.stringnotation.NormalWords; |
| 47 | +import static de.joshuagleitze.stringnotation.StringToWord.fromNotation; |
| 48 | + |
| 49 | +// 1 Type Name 4 You! -> TypeName4You |
| 50 | +fromNotation("1 Type Name 4 You!", NormalWords.INSTANCE).toNotation(JavaTypeName.INSTANCE); |
| 51 | +``` |
| 52 | + |
| 53 | +## [Contributions welcome](http://contributionswelcome.org/) |
| 54 | + |
| 55 | +All contributions (no matter if small) are always welcome. |
| 56 | + |
0 commit comments