KeyEscapeUtil { public static String escape(final String str) { requireNonNull(str); return str.replace("~", FAKE_TILDA) .replace("$", FAKE_DOLLAR) .replace(".", FAKE_DOT); } private  KeyEscapeUtil(); static String escape(final String str); static final String FAKE_DOT; }
@Test public void escape() { assertSame("escapingNotNecessary", KeyEscapeUtil.escape("escapingNotNecessary")); assertEquals("~1org~2eclipse~2~0ditto", KeyEscapeUtil.escape("$org.eclipse.~ditto")); }