LocalizationUtil { public static String getEnumLocalizationKey(Enum<?> e) { if (Localizable.class.isAssignableFrom(e.getClass())) return ((Localizable) e).getKey(); return new StringBuilder(e.getDeclaringClass().getName()).append(".").append(e.name()).toString(); } private  LocalizationUtil(); static String getEnumLocalizationKey(Enum<?> e);  }
@Test public void testGetEnumLocalizationKey() throws Exception { Assert.assertEquals("cz.datalite.localization.TestEnumPlain.FOO", LocalizationUtil.getEnumLocalizationKey(TestEnumPlain.FOO)); try { LocalizationUtil.getEnumLocalizationKey(null); fail("Should fail on NPE"); } catch (NullPointerException expexted) { } Assert.assertEquals("foo.bar", LocalizationUtil.getEnumLocalizationKey(TestEnum.FOO)); }