ColorNames { @Pure public static int getColorFromName(String colorName, int defaultValue) { final Integer value = COLOR_MATCHES.get(Strings.nullToEmpty(colorName).toLowerCase()); if (value != null) { return value.intValue(); } return defaultValue; } private  ColorNames(); @Pure static Set<String> getColorNames(); @Pure static Map<String, Integer> getColorDefinitions(); @Pure static int getColorFromName(String colorName, int defaultValue); @Pure static Integer getColorFromName(String colorName); @Pure static String getColorNameFromValue(int colorValue); static final String TRANSPARENT; static final String WHITE; static final String LIGHT_GRAY; static final String GRAY; static final String DARK_GRAY; static final String BLACK; static final String RED; static final String PINK; static final String ORANGE; static final String YELLOW; static final String GREEN; static final String MAGENTA; static final String CYAN; static final String BLUE; }
@Test public void getColorFromNameStringInt() { for (String nm : NAMES) { assertNotEquals(0xFFFFFF, ColorNames.getColorFromName(nm, 0xFFFFFF), "Invalid color: " + nm); } }
@Test public void getColorFromNameString() { for (String nm : NAMES) { assertNotNull(ColorNames.getColorFromName(nm), "Invalid color: " + nm); } }