Util { public static String toJavaConstantIdentifier(String name) { StringBuilder s = new StringBuilder(); boolean funnyCharacter = false; for (int i = 0; i < name.length(); i++) { char ch = name.charAt(i); if ((i == 0 && !Character.isJavaIdentifierStart(ch)) || (i > 0 && !Character.isJavaIdentifierPart(ch))) { funnyCharacter = true; } else if (funnyCharacter) { s.append("_"); s.append(Character.toUpperCase(ch)); funnyCharacter = false; } else s.append(Character.toUpperCase(ch)); } return s.toString(); }  static String getMultiplicityAbbreviation(Perspective p); static String lowerFirst(String s); static String upperFirst(String s); static String toClassSimpleName(String name); static String toJavaIdentifier(String name); static String toJavaConstantIdentifier(String name); static String camelCaseToLowerUnderscore(String s); static String toTableName(String className); static String toTableIdName(String className); static String toColumnName(String attributeName); static ModeledDomain getModeledDomain(Domains domains, String name); static ModeledDomain getModeledDomain(InputStream is, String domainName); static String getPackage(String className); static String getSimpleClassName(String className); static List<Class> getClasses(ModeledDomain domain);  }
@Test public void testToJavaConstantIdentifierEndsWithDigit() { assertEquals("STATE1", Util.toJavaConstantIdentifier("State1")); }
@Test public void testToJavaConstantIdentifierHasSpaces() { String s = Util.toJavaConstantIdentifier("State 1"); System.out.println(s); assertEquals("STATE_1", s); }