April 15, 2015
Convert Strings from hyphen-notation to camel case (Java / Guava)
There are many ways how to sperate words in a String for us programmers. One of the most popular are seperation by “hyphens” and using the CamelCase Notation. The library Guava from Google provides excellent help for converting a string from one format to the other
Hyphen Format
| 
					 1  | 
						String string = "i-am-a-string"  | 
					
Camel Case Format (Wikipedia)
| 
					 1  | 
						String string = "iAmAString"  | 
					
Conversion in Java (using Google Guava)
The class CaseFormat provides useful helpers to convert Strings from hyphen format to CamelCase and vice versa.
| 
					 1 2 3  | 
						String temp = "capitalize-me"; String result = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL, temp); System.out.println(result); //produces "capitalizeMe"  | 
					
Upcoming
Next time I will show you how to do the same thing with an AngularJS directive.
