@Test public void testColor() { Factory factory = new Factory(); assertEquals(new Color(0xFF0000), ((Literal) Util.color("FF0000", factory)).getValue()); assertEquals(new Color(0x00FF00), ((Literal) Util.color("00ff00", factory)).getValue()); assertEquals(new Color(0x0000FF), ((Literal) Util.color("#0000FF", factory)).getValue()); assertEquals(new Color(0xFFFF00), ((Literal) Util.color("0xFFFF00", factory)).getValue()); assertEquals( new Color(0x00FFFF), ((Literal) Util.color("rgb(0, 255, 255)", factory)).getValue()); assertEquals(new Color(0xFF00FF), ((Literal) Util.color("f0f", factory)).getValue()); }
public static Expression color(Object value, Factory factory) { Color color = null; if (value instanceof String) { Matcher m = HEX_PATTERN.matcher((String) value); if (m.matches()) { color = parseColorAsHex(m); } if (color == null) { m = RGB_PATTERN.matcher((String) value); if (m.matches()) { color = parseColorAsRGB(m); } } if (color == null) { color = Colors.get((String) value); } } else if (value instanceof Integer) { color = new Color((int) value); } if (value != null) value = value.toString(); return color != null ? factory.filter.literal(color) : expression((String) value, factory); }
Util { public static Expression color(Object value, Factory factory) { Color color = null; if (value instanceof String) { Matcher m = HEX_PATTERN.matcher((String) value); if (m.matches()) { color = parseColorAsHex(m); } if (color == null) { m = RGB_PATTERN.matcher((String) value); if (m.matches()) { color = parseColorAsRGB(m); } } if (color == null) { color = Colors.get((String) value); } } else if (value instanceof Integer) { color = new Color((int) value); } if (value != null) value = value.toString(); return color != null ? factory.filter.literal(color) : expression((String) value, factory); } }
Util { public static Expression color(Object value, Factory factory) { Color color = null; if (value instanceof String) { Matcher m = HEX_PATTERN.matcher((String) value); if (m.matches()) { color = parseColorAsHex(m); } if (color == null) { m = RGB_PATTERN.matcher((String) value); if (m.matches()) { color = parseColorAsRGB(m); } } if (color == null) { color = Colors.get((String) value); } } else if (value instanceof Integer) { color = new Color((int) value); } if (value != null) value = value.toString(); return color != null ? factory.filter.literal(color) : expression((String) value, factory); }  }
Util { public static Expression color(Object value, Factory factory) { Color color = null; if (value instanceof String) { Matcher m = HEX_PATTERN.matcher((String) value); if (m.matches()) { color = parseColorAsHex(m); } if (color == null) { m = RGB_PATTERN.matcher((String) value); if (m.matches()) { color = parseColorAsRGB(m); } } if (color == null) { color = Colors.get((String) value); } } else if (value instanceof Integer) { color = new Color((int) value); } if (value != null) value = value.toString(); return color != null ? factory.filter.literal(color) : expression((String) value, factory); }  static Expression expression(String value, Factory factory); static Expression unwrapConcatenates(Expression expr, Factory factory); static List<Expression> splitConcatenates(Expression expr); static Expression expression(String value, boolean safe, Factory factory); static AnchorPoint anchor(Object value, Factory factory); static Displacement displacement(Object value, Factory factory); static Expression color(Object value, Factory factory); static float[] floatArray(String value); @SafeVarargs @Nullable static T defaultForNull(@Nullable T... options); @SafeVarargs static T forceDefaultForNull(@Nullable T... options); static @Nullable ZoomContext getNamedZoomContext(
            String name, List<ZoomContextFinder> zCtxtFinders); static String removeExpressionBrackets(String s); static Object makeNumberIfPossible(String str); static String serializeColor(Color c); static String stripQuotes(String str); static Map<String, String> vendorOptions(YamlMap sourceMap); }
Util { public static Expression color(Object value, Factory factory) { Color color = null; if (value instanceof String) { Matcher m = HEX_PATTERN.matcher((String) value); if (m.matches()) { color = parseColorAsHex(m); } if (color == null) { m = RGB_PATTERN.matcher((String) value); if (m.matches()) { color = parseColorAsRGB(m); } } if (color == null) { color = Colors.get((String) value); } } else if (value instanceof Integer) { color = new Color((int) value); } if (value != null) value = value.toString(); return color != null ? factory.filter.literal(color) : expression((String) value, factory); }  static Expression expression(String value, Factory factory); static Expression unwrapConcatenates(Expression expr, Factory factory); static List<Expression> splitConcatenates(Expression expr); static Expression expression(String value, boolean safe, Factory factory); static AnchorPoint anchor(Object value, Factory factory); static Displacement displacement(Object value, Factory factory); static Expression color(Object value, Factory factory); static float[] floatArray(String value); @SafeVarargs @Nullable static T defaultForNull(@Nullable T... options); @SafeVarargs static T forceDefaultForNull(@Nullable T... options); static @Nullable ZoomContext getNamedZoomContext(
            String name, List<ZoomContextFinder> zCtxtFinders); static String removeExpressionBrackets(String s); static Object makeNumberIfPossible(String str); static String serializeColor(Color c); static String stripQuotes(String str); static Map<String, String> vendorOptions(YamlMap sourceMap);  }