DefUtils { public static String toIdentifier( String name) { return nonIdentifierCharRegex_.matcher( toNumberIdentifiers( name).replaceAll( "\\s+", "-")) .replaceAll( ""); } private  DefUtils(); static boolean isIdentifier( String id); static String[] toPath( String pathName); static void assertIdentifier( String id); static boolean isVarValue( Object val); static void assertVarValue( Object val); static void assertPath( String pathName); static void assertPropertyIdentifiers( Collection<String> properties); static String toIdentifier( String name); static String toIdentifier( Number number); static String toNumberIdentifiers( String text);  }
@Test public void toIdentifier() { assertEquals( "1234", DefUtils.toIdentifier( 1234)); assertEquals( "m1234", DefUtils.toIdentifier( -1234)); assertEquals( "m1234d56", DefUtils.toIdentifier( new BigDecimal( "-1234.56"))); assertEquals( "Is-1d2-negative", DefUtils.toIdentifier( "Is (1.2) negative?")); }