public static String toHeadlessCamelCaseName ( String html5DataName ) { if ( StringUtils . isEmpty ( html5DataName ) ) { throw new IllegalArgumentException ( "Property name is empty." ) ; } if ( ! isHtml5DataName ( html5DataName ) ) { throw new IllegalArgumentException ( "This is not a valid HTML5 data property name: " + html5DataName ) ; } String html5DataNameWithoutSuffix = StringUtils . substringAfter ( html5DataName , HTML5_DATA_PREFIX ) ; StringBuilder headlessCamelCaseName = new StringBuilder ( ) ; boolean upperCaseNext = false ; for ( int i = 0 ; i < html5DataNameWithoutSuffix . length ( ) ; i ++ ) { char c = html5DataNameWithoutSuffix . charAt ( i ) ; if ( c == ' ' ) { upperCaseNext = true ; } else if ( upperCaseNext ) { headlessCamelCaseName . append ( Character . toUpperCase ( c ) ) ; upperCaseNext = false ; } else { headlessCamelCaseName . append ( c ) ; } } return headlessCamelCaseName . toString ( ) ; }
Converts a HTML5 data attribute name including data - prefix to a headless camel case name .