@Test public void fromJsonString_backToJson_createsIdenticalElement() { try { JSONObject rawConversion = new JSONObject(EXAMPLE_JSON_RECEIVER); assertJsonEquals(rawConversion, mSourceReceiver.toJson()); } catch (JSONException jsonException) { fail("Test Data failure: " + jsonException.getLocalizedMessage()); } }
@NonNull @Override public JSONObject toJson() { JSONObject jsonObject = new JSONObject(); StripeJsonUtils.putStringIfNotNull(jsonObject, FIELD_ADDRESS, mAddress); try { jsonObject.put(FIELD_AMOUNT_CHARGED, mAmountCharged); jsonObject.put(FIELD_AMOUNT_RECEIVED, mAmountReceived); jsonObject.put(FIELD_AMOUNT_RETURNED, mAmountReturned); } catch (JSONException jsonException) { return jsonObject; } return jsonObject; }
SourceReceiver extends StripeJsonModel { @NonNull @Override public JSONObject toJson() { JSONObject jsonObject = new JSONObject(); StripeJsonUtils.putStringIfNotNull(jsonObject, FIELD_ADDRESS, mAddress); try { jsonObject.put(FIELD_AMOUNT_CHARGED, mAmountCharged); jsonObject.put(FIELD_AMOUNT_RECEIVED, mAmountReceived); jsonObject.put(FIELD_AMOUNT_RETURNED, mAmountReturned); } catch (JSONException jsonException) { return jsonObject; } return jsonObject; } }
SourceReceiver extends StripeJsonModel { @NonNull @Override public JSONObject toJson() { JSONObject jsonObject = new JSONObject(); StripeJsonUtils.putStringIfNotNull(jsonObject, FIELD_ADDRESS, mAddress); try { jsonObject.put(FIELD_AMOUNT_CHARGED, mAmountCharged); jsonObject.put(FIELD_AMOUNT_RECEIVED, mAmountReceived); jsonObject.put(FIELD_AMOUNT_RETURNED, mAmountReturned); } catch (JSONException jsonException) { return jsonObject; } return jsonObject; } SourceReceiver(String address,
                   long amountCharged,
                   long amountReceived,
                   long amountReturned); }
SourceReceiver extends StripeJsonModel { @NonNull @Override public JSONObject toJson() { JSONObject jsonObject = new JSONObject(); StripeJsonUtils.putStringIfNotNull(jsonObject, FIELD_ADDRESS, mAddress); try { jsonObject.put(FIELD_AMOUNT_CHARGED, mAmountCharged); jsonObject.put(FIELD_AMOUNT_RECEIVED, mAmountReceived); jsonObject.put(FIELD_AMOUNT_RETURNED, mAmountReturned); } catch (JSONException jsonException) { return jsonObject; } return jsonObject; } SourceReceiver(String address,
                   long amountCharged,
                   long amountReceived,
                   long amountReturned); String getAddress(); void setAddress(String address); long getAmountCharged(); void setAmountCharged(long amountCharged); long getAmountReceived(); void setAmountReceived(long amountReceived); long getAmountReturned(); void setAmountReturned(long amountReturned); @NonNull @Override Map<String, Object> toMap(); @NonNull @Override JSONObject toJson(); @Nullable static SourceReceiver fromString(@Nullable String jsonString); @Nullable static SourceReceiver fromJson(@Nullable JSONObject jsonObject); }
SourceReceiver extends StripeJsonModel { @NonNull @Override public JSONObject toJson() { JSONObject jsonObject = new JSONObject(); StripeJsonUtils.putStringIfNotNull(jsonObject, FIELD_ADDRESS, mAddress); try { jsonObject.put(FIELD_AMOUNT_CHARGED, mAmountCharged); jsonObject.put(FIELD_AMOUNT_RECEIVED, mAmountReceived); jsonObject.put(FIELD_AMOUNT_RETURNED, mAmountReturned); } catch (JSONException jsonException) { return jsonObject; } return jsonObject; } SourceReceiver(String address,
                   long amountCharged,
                   long amountReceived,
                   long amountReturned); String getAddress(); void setAddress(String address); long getAmountCharged(); void setAmountCharged(long amountCharged); long getAmountReceived(); void setAmountReceived(long amountReceived); long getAmountReturned(); void setAmountReturned(long amountReturned); @NonNull @Override Map<String, Object> toMap(); @NonNull @Override JSONObject toJson(); @Nullable static SourceReceiver fromString(@Nullable String jsonString); @Nullable static SourceReceiver fromJson(@Nullable JSONObject jsonObject);  }