@Test public void testColorFromFunction() throws ParseException { JSONObject object = MapboxTestUtils.object("{'expr': {'property':'color','type':'identity'}}"); Expression expression = parser.color(object, "expr", Color.black); assertTrue( "Parse result must be a function", Function.class.isAssignableFrom(expression.getClass())); }
public Expression color(JSONObject json, String name, Color fallback) throws MBFormatException { if (json.get(name) == null) { return fallback == null ? null : ff.literal(fallback); } Object obj = json.get(name); return color("\"" + name + "\"", obj, fallback); }
MBObjectParser { public Expression color(JSONObject json, String name, Color fallback) throws MBFormatException { if (json.get(name) == null) { return fallback == null ? null : ff.literal(fallback); } Object obj = json.get(name); return color("\"" + name + "\"", obj, fallback); } }
MBObjectParser { public Expression color(JSONObject json, String name, Color fallback) throws MBFormatException { if (json.get(name) == null) { return fallback == null ? null : ff.literal(fallback); } Object obj = json.get(name); return color("\"" + name + "\"", obj, fallback); } MBObjectParser(Class<?> context);  MBObjectParser(Class<MBFilter> context, MBObjectParser parse); }
MBObjectParser { public Expression color(JSONObject json, String name, Color fallback) throws MBFormatException { if (json.get(name) == null) { return fallback == null ? null : ff.literal(fallback); } Object obj = json.get(name); return color("\"" + name + "\"", obj, fallback); } MBObjectParser(Class<?> context);  MBObjectParser(Class<MBFilter> context, MBObjectParser parse); FilterFactory2 getFilterFactory(); StyleFactory2 getStyleFactory(); JSONObject paint(JSONObject layer); JSONObject layout(JSONObject layer); JSONObject getJSONObject(JSONObject json, String name); JSONObject getJSONObject(JSONObject json, String name, JSONObject fallback); JSONArray getJSONArray(JSONObject json, String name); JSONArray getJSONArray(JSONObject json, String name, JSONArray fallback); Object value(JSONArray json, int index); Object value(JSONObject json, String name); String get(JSONArray json, int index); String get(JSONObject json, String name); String get(JSONObject json, String name, String fallback); double getNumeric(JSONArray json, int index); Double getNumeric(JSONObject json, String name); Boolean getBoolean(JSONArray json, int index); Boolean getBoolean(JSONObject json, String name); Boolean getBoolean(JSONObject json, String name, Boolean fallback); T require(Class<T> type, JSONArray json, int index); T require(Class<T> type, JSONObject json, String name); T optional(Class<T> type, JSONObject json, String name, T fallback); T getEnum(
            JSONObject json, String name, Class<T> enumeration, T fallback); Expression enumToExpression(
            JSONObject json, String name, Class<T> enumeration, T fallback); Literal constant(Object value, Class<? extends Enum<?>> enumeration); JSONObject jsonObject(Object obj); JSONObject jsonObect(Object obj, String message); JSONArray jsonArray(Object obj); JSONArray jsonArray(Object obj, String message); @SuppressWarnings("unchecked") T[] array(Class<T> type, JSONObject json, String name, T[] fallback); int[] array(JSONObject json, String name, int[] fallback); double[] array(JSONObject json, String name, double[] fallback); Expression percentage(JSONObject json, String name); Expression percentage(JSONObject json, String name, Number fallback); Expression font(JSONObject json, String name); Expression number(JSONArray json, int index); Expression number(JSONArray json, int index, Number fallback); Expression number(JSONObject json, String name); Expression number(JSONObject json, String name, Number fallback); Expression string(JSONArray json, int index); Expression string(JSONObject json, String name, String fallback); Expression color(JSONObject json, String name, Color fallback); Literal color(String color); Color convertToColor(String color); Expression bool(JSONObject json, String name, boolean fallback); Displacement displacement(JSONObject json, String name, Displacement fallback); @Deprecated boolean isPropertyDefined(JSONObject json, String propertyName); boolean isDefined(JSONObject json, String name); boolean isDefined(JSONArray json, int index); boolean isString(JSONObject json, String name); boolean isString(JSONArray json, int index); boolean isNumeric(JSONObject json, String name); boolean isNumeric(JSONArray json, int index); boolean isBoolean(JSONObject json, String name); boolean isBoolean(JSONArray json, int index); boolean isArray(JSONObject json, String name); boolean isArray(JSONArray json, int index); boolean isObject(JSONObject json, String name); boolean isObject(JSONArray json, int index); }
MBObjectParser { public Expression color(JSONObject json, String name, Color fallback) throws MBFormatException { if (json.get(name) == null) { return fallback == null ? null : ff.literal(fallback); } Object obj = json.get(name); return color("\"" + name + "\"", obj, fallback); } MBObjectParser(Class<?> context);  MBObjectParser(Class<MBFilter> context, MBObjectParser parse); FilterFactory2 getFilterFactory(); StyleFactory2 getStyleFactory(); JSONObject paint(JSONObject layer); JSONObject layout(JSONObject layer); JSONObject getJSONObject(JSONObject json, String name); JSONObject getJSONObject(JSONObject json, String name, JSONObject fallback); JSONArray getJSONArray(JSONObject json, String name); JSONArray getJSONArray(JSONObject json, String name, JSONArray fallback); Object value(JSONArray json, int index); Object value(JSONObject json, String name); String get(JSONArray json, int index); String get(JSONObject json, String name); String get(JSONObject json, String name, String fallback); double getNumeric(JSONArray json, int index); Double getNumeric(JSONObject json, String name); Boolean getBoolean(JSONArray json, int index); Boolean getBoolean(JSONObject json, String name); Boolean getBoolean(JSONObject json, String name, Boolean fallback); T require(Class<T> type, JSONArray json, int index); T require(Class<T> type, JSONObject json, String name); T optional(Class<T> type, JSONObject json, String name, T fallback); T getEnum(
            JSONObject json, String name, Class<T> enumeration, T fallback); Expression enumToExpression(
            JSONObject json, String name, Class<T> enumeration, T fallback); Literal constant(Object value, Class<? extends Enum<?>> enumeration); JSONObject jsonObject(Object obj); JSONObject jsonObect(Object obj, String message); JSONArray jsonArray(Object obj); JSONArray jsonArray(Object obj, String message); @SuppressWarnings("unchecked") T[] array(Class<T> type, JSONObject json, String name, T[] fallback); int[] array(JSONObject json, String name, int[] fallback); double[] array(JSONObject json, String name, double[] fallback); Expression percentage(JSONObject json, String name); Expression percentage(JSONObject json, String name, Number fallback); Expression font(JSONObject json, String name); Expression number(JSONArray json, int index); Expression number(JSONArray json, int index, Number fallback); Expression number(JSONObject json, String name); Expression number(JSONObject json, String name, Number fallback); Expression string(JSONArray json, int index); Expression string(JSONObject json, String name, String fallback); Expression color(JSONObject json, String name, Color fallback); Literal color(String color); Color convertToColor(String color); Expression bool(JSONObject json, String name, boolean fallback); Displacement displacement(JSONObject json, String name, Displacement fallback); @Deprecated boolean isPropertyDefined(JSONObject json, String propertyName); boolean isDefined(JSONObject json, String name); boolean isDefined(JSONArray json, int index); boolean isString(JSONObject json, String name); boolean isString(JSONArray json, int index); boolean isNumeric(JSONObject json, String name); boolean isNumeric(JSONArray json, int index); boolean isBoolean(JSONObject json, String name); boolean isBoolean(JSONArray json, int index); boolean isArray(JSONObject json, String name); boolean isArray(JSONArray json, int index); boolean isObject(JSONObject json, String name); boolean isObject(JSONArray json, int index);  }