@Test public void enumDefaultFunctionTest() throws Exception { String jsonStr = "{'property': 'temperature','stops': [[0, 'ENUM_VAL1'],[100, 'ENUM_VAL2'],[1000, 'ENUM_VAL3']]}"; MBFunction function = new MBFunction(MapboxTestUtils.object(jsonStr)); assertEquals( "The default function type for Enums returns should be interval", FunctionType.INTERVAL, function.getTypeWithDefault(Enumeration.class)); }
public FunctionType getTypeWithDefault(Class<?> clazz) { FunctionType declaredType = getType(); if (declaredType != null) { return declaredType; } if (Color.class.isAssignableFrom(clazz) || Number.class.isAssignableFrom(clazz)) { return FunctionType.EXPONENTIAL; } else { return FunctionType.INTERVAL; } }
MBFunction { public FunctionType getTypeWithDefault(Class<?> clazz) { FunctionType declaredType = getType(); if (declaredType != null) { return declaredType; } if (Color.class.isAssignableFrom(clazz) || Number.class.isAssignableFrom(clazz)) { return FunctionType.EXPONENTIAL; } else { return FunctionType.INTERVAL; } } }
MBFunction { public FunctionType getTypeWithDefault(Class<?> clazz) { FunctionType declaredType = getType(); if (declaredType != null) { return declaredType; } if (Color.class.isAssignableFrom(clazz) || Number.class.isAssignableFrom(clazz)) { return FunctionType.EXPONENTIAL; } else { return FunctionType.INTERVAL; } } MBFunction(JSONObject json);  MBFunction(MBObjectParser parse, JSONObject json); }
MBFunction { public FunctionType getTypeWithDefault(Class<?> clazz) { FunctionType declaredType = getType(); if (declaredType != null) { return declaredType; } if (Color.class.isAssignableFrom(clazz) || Number.class.isAssignableFrom(clazz)) { return FunctionType.EXPONENTIAL; } else { return FunctionType.INTERVAL; } } MBFunction(JSONObject json);  MBFunction(MBObjectParser parse, JSONObject json); FunctionType getType(); Object getDefault(); FunctionType getTypeWithDefault(Class<?> clazz); String getProperty(); EnumSet<FunctionCategory> category(); JSONArray getStops(); Number getBase(); static MBFunction create(JSONObject json); Expression color(); Expression font(); Expression numeric(); @SuppressWarnings("unchecked") Expression function(Class<?> clazz); Expression enumeration(Class<? extends Enum<?>> enumeration); boolean isArrayFunction(); List<MBFunction> splitArrayFunction(); }
MBFunction { public FunctionType getTypeWithDefault(Class<?> clazz) { FunctionType declaredType = getType(); if (declaredType != null) { return declaredType; } if (Color.class.isAssignableFrom(clazz) || Number.class.isAssignableFrom(clazz)) { return FunctionType.EXPONENTIAL; } else { return FunctionType.INTERVAL; } } MBFunction(JSONObject json);  MBFunction(MBObjectParser parse, JSONObject json); FunctionType getType(); Object getDefault(); FunctionType getTypeWithDefault(Class<?> clazz); String getProperty(); EnumSet<FunctionCategory> category(); JSONArray getStops(); Number getBase(); static MBFunction create(JSONObject json); Expression color(); Expression font(); Expression numeric(); @SuppressWarnings("unchecked") Expression function(Class<?> clazz); Expression enumeration(Class<? extends Enum<?>> enumeration); boolean isArrayFunction(); List<MBFunction> splitArrayFunction();  }