| 315 | */ |
| 316 | // TODO(gak): maybe this should be a function of TypeMirrors instead of Elements? |
| 317 | static String simpleVariableName(TypeElement typeElement) { |
| 318 | String candidateName = UPPER_CAMEL.to(LOWER_CAMEL, typeElement.getSimpleName().toString()); |
| 319 | String variableName = protectAgainstKeywords(candidateName); |
| 320 | verify(isName(variableName), "'%s' was expected to be a valid variable name"); |
| 321 | return variableName; |
| 322 | } |
| 323 | |
| 324 | private static String protectAgainstKeywords(String candidateName) { |
| 325 | switch (candidateName) { |