@Test public void colorDefaultFunctionTest() throws Exception { JSONObject json = MapboxTestUtils.object( "{'property':'temperature','stops':[[0,'blue'],[100,'red']]}"); MBFunction function = new MBFunction(json); assertEquals( "The default function type for Color returns should be exponential", FunctionType.EXPONENTIAL, function.getTypeWithDefault(Color.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();  }