@Test public void putAdditionalFieldsIntoJsonObject_whenNullPassedInEitherArgument_doesNothing() { Map<String, Object> littleMap = new HashMap<String, Object>() {{ put("a", "a_value"); }}; JSONObject jsonObject = new JSONObject(); putAdditionalFieldsIntoJsonObject(null, littleMap); putAdditionalFieldsIntoJsonObject(jsonObject, null); assertEquals(0, jsonObject.length()); }
static void putAdditionalFieldsIntoJsonObject( @Nullable JSONObject jsonObject, @Nullable Map<String, Object> additionalFields) { if (jsonObject == null || additionalFields == null || additionalFields.isEmpty()) { return; } for (String key : additionalFields.keySet()) { try { if (additionalFields.get(key) != null) { jsonObject.put(key, additionalFields.get(key)); } } catch (JSONException ignored) { } } }
StripeSourceTypeModel extends StripeJsonModel { static void putAdditionalFieldsIntoJsonObject( @Nullable JSONObject jsonObject, @Nullable Map<String, Object> additionalFields) { if (jsonObject == null || additionalFields == null || additionalFields.isEmpty()) { return; } for (String key : additionalFields.keySet()) { try { if (additionalFields.get(key) != null) { jsonObject.put(key, additionalFields.get(key)); } } catch (JSONException ignored) { } } } }
StripeSourceTypeModel extends StripeJsonModel { static void putAdditionalFieldsIntoJsonObject( @Nullable JSONObject jsonObject, @Nullable Map<String, Object> additionalFields) { if (jsonObject == null || additionalFields == null || additionalFields.isEmpty()) { return; } for (String key : additionalFields.keySet()) { try { if (additionalFields.get(key) != null) { jsonObject.put(key, additionalFields.get(key)); } } catch (JSONException ignored) { } } } StripeSourceTypeModel(); }
StripeSourceTypeModel extends StripeJsonModel { static void putAdditionalFieldsIntoJsonObject( @Nullable JSONObject jsonObject, @Nullable Map<String, Object> additionalFields) { if (jsonObject == null || additionalFields == null || additionalFields.isEmpty()) { return; } for (String key : additionalFields.keySet()) { try { if (additionalFields.get(key) != null) { jsonObject.put(key, additionalFields.get(key)); } } catch (JSONException ignored) { } } } StripeSourceTypeModel(); @NonNull Map<String, Object> getAdditionalFields(); }
StripeSourceTypeModel extends StripeJsonModel { static void putAdditionalFieldsIntoJsonObject( @Nullable JSONObject jsonObject, @Nullable Map<String, Object> additionalFields) { if (jsonObject == null || additionalFields == null || additionalFields.isEmpty()) { return; } for (String key : additionalFields.keySet()) { try { if (additionalFields.get(key) != null) { jsonObject.put(key, additionalFields.get(key)); } } catch (JSONException ignored) { } } } StripeSourceTypeModel(); @NonNull Map<String, Object> getAdditionalFields();  }