@Test public void testToJsonObject() throws JSONException, InvalidMapBoxStyleException { String dataField1 = "test"; SortFieldConfig.FieldType type1 = SortFieldConfig.FieldType.NUMBER; SortFieldConfig config1 = new SortFieldConfig(type1, dataField1); Assert.assertEquals(config1.toJsonObject() .getString(SortFieldConfig.KEY_TYPE).toLowerCase(), type1.toString().toLowerCase()); Assert.assertEquals(config1.toJsonObject() .getString(SortFieldConfig.KEY_DATA_FIELD).toLowerCase(), dataField1.toLowerCase()); JSONObject object1 = new JSONObject(); object1.put(SortFieldConfig.KEY_DATA_FIELD, dataField1); object1.put(SortFieldConfig.KEY_TYPE, type1.toString()); SortFieldConfig config2 = new SortFieldConfig(object1); Assert.assertEquals(config2.toJsonObject() .getString(SortFieldConfig.KEY_TYPE).toLowerCase(), type1.toString().toLowerCase()); Assert.assertEquals(config2.toJsonObject() .getString(SortFieldConfig.KEY_DATA_FIELD).toLowerCase(), dataField1.toLowerCase()); Assert.assertNotSame(object1, config2.toJsonObject()); }
@Override public JSONObject toJsonObject() throws JSONException { JSONObject object = new JSONObject(); object.put(KEY_TYPE, type.toString().toLowerCase()); object.put(KEY_DATA_FIELD, dataField); return object; }
SortFieldConfig implements Config { @Override public JSONObject toJsonObject() throws JSONException { JSONObject object = new JSONObject(); object.put(KEY_TYPE, type.toString().toLowerCase()); object.put(KEY_DATA_FIELD, dataField); return object; } }
SortFieldConfig implements Config { @Override public JSONObject toJsonObject() throws JSONException { JSONObject object = new JSONObject(); object.put(KEY_TYPE, type.toString().toLowerCase()); object.put(KEY_DATA_FIELD, dataField); return object; } SortFieldConfig(@NonNull FieldType fieldType, @NonNull String dataField);  SortFieldConfig(@NonNull String type, @NonNull String dataField);  SortFieldConfig(@NonNull JSONObject jsonObject);  SortFieldConfig(); }
SortFieldConfig implements Config { @Override public JSONObject toJsonObject() throws JSONException { JSONObject object = new JSONObject(); object.put(KEY_TYPE, type.toString().toLowerCase()); object.put(KEY_DATA_FIELD, dataField); return object; } SortFieldConfig(@NonNull FieldType fieldType, @NonNull String dataField);  SortFieldConfig(@NonNull String type, @NonNull String dataField);  SortFieldConfig(@NonNull JSONObject jsonObject);  SortFieldConfig(); FieldType getType(); void setType(@NonNull FieldType type); void setType(@NonNull String type); static boolean isValidType(String type); String getDataField(); void setDataField(@NonNull String dataField); static SortFieldConfig[] extractSortFieldConfigs(@NonNull MapBoxStyleHelper styleHelper); @Override boolean isValid(); @Override JSONObject toJsonObject(); }
SortFieldConfig implements Config { @Override public JSONObject toJsonObject() throws JSONException { JSONObject object = new JSONObject(); object.put(KEY_TYPE, type.toString().toLowerCase()); object.put(KEY_DATA_FIELD, dataField); return object; } SortFieldConfig(@NonNull FieldType fieldType, @NonNull String dataField);  SortFieldConfig(@NonNull String type, @NonNull String dataField);  SortFieldConfig(@NonNull JSONObject jsonObject);  SortFieldConfig(); FieldType getType(); void setType(@NonNull FieldType type); void setType(@NonNull String type); static boolean isValidType(String type); String getDataField(); void setDataField(@NonNull String dataField); static SortFieldConfig[] extractSortFieldConfigs(@NonNull MapBoxStyleHelper styleHelper); @Override boolean isValid(); @Override JSONObject toJsonObject(); static final String KEY_DATA_FIELD; static final String KEY_TYPE; }