@Test public void fromJsonStringWithoutNulls_backToJson_createsIdenticalElement() { try { JSONObject rawConversion = new JSONObject(EXAMPLE_JSON_OWNER_WITHOUT_NULLS); assertJsonEquals(rawConversion, mSourceOwner.toJson()); } catch (JSONException jsonException) { fail("Test Data failure: " + jsonException.getLocalizedMessage()); } }
@NonNull @Override public JSONObject toJson() { JSONObject jsonObject = new JSONObject(); JSONObject jsonAddressObject = mAddress == null ? null : mAddress.toJson(); JSONObject jsonVerifiedAddressObject = mVerifiedAddress == null ? null : mVerifiedAddress.toJson(); try { if (jsonAddressObject != null && jsonAddressObject.length() > 0) { jsonObject.put(FIELD_ADDRESS, jsonAddressObject); } putStringIfNotNull(jsonObject, FIELD_EMAIL, mEmail); putStringIfNotNull(jsonObject, FIELD_NAME, mName); putStringIfNotNull(jsonObject, FIELD_PHONE, mPhone); if (jsonVerifiedAddressObject != null && jsonVerifiedAddressObject.length() > 0) { jsonObject.put(FIELD_VERIFIED_ADDRESS, jsonVerifiedAddressObject); } putStringIfNotNull(jsonObject, FIELD_VERIFIED_EMAIL, mVerifiedEmail); putStringIfNotNull(jsonObject, FIELD_VERIFIED_NAME, mVerifiedName); putStringIfNotNull(jsonObject, FIELD_VERIFIED_PHONE, mVerifiedPhone); } catch (JSONException ignored) { } return jsonObject; }
SourceOwner extends StripeJsonModel { @NonNull @Override public JSONObject toJson() { JSONObject jsonObject = new JSONObject(); JSONObject jsonAddressObject = mAddress == null ? null : mAddress.toJson(); JSONObject jsonVerifiedAddressObject = mVerifiedAddress == null ? null : mVerifiedAddress.toJson(); try { if (jsonAddressObject != null && jsonAddressObject.length() > 0) { jsonObject.put(FIELD_ADDRESS, jsonAddressObject); } putStringIfNotNull(jsonObject, FIELD_EMAIL, mEmail); putStringIfNotNull(jsonObject, FIELD_NAME, mName); putStringIfNotNull(jsonObject, FIELD_PHONE, mPhone); if (jsonVerifiedAddressObject != null && jsonVerifiedAddressObject.length() > 0) { jsonObject.put(FIELD_VERIFIED_ADDRESS, jsonVerifiedAddressObject); } putStringIfNotNull(jsonObject, FIELD_VERIFIED_EMAIL, mVerifiedEmail); putStringIfNotNull(jsonObject, FIELD_VERIFIED_NAME, mVerifiedName); putStringIfNotNull(jsonObject, FIELD_VERIFIED_PHONE, mVerifiedPhone); } catch (JSONException ignored) { } return jsonObject; } }
SourceOwner extends StripeJsonModel { @NonNull @Override public JSONObject toJson() { JSONObject jsonObject = new JSONObject(); JSONObject jsonAddressObject = mAddress == null ? null : mAddress.toJson(); JSONObject jsonVerifiedAddressObject = mVerifiedAddress == null ? null : mVerifiedAddress.toJson(); try { if (jsonAddressObject != null && jsonAddressObject.length() > 0) { jsonObject.put(FIELD_ADDRESS, jsonAddressObject); } putStringIfNotNull(jsonObject, FIELD_EMAIL, mEmail); putStringIfNotNull(jsonObject, FIELD_NAME, mName); putStringIfNotNull(jsonObject, FIELD_PHONE, mPhone); if (jsonVerifiedAddressObject != null && jsonVerifiedAddressObject.length() > 0) { jsonObject.put(FIELD_VERIFIED_ADDRESS, jsonVerifiedAddressObject); } putStringIfNotNull(jsonObject, FIELD_VERIFIED_EMAIL, mVerifiedEmail); putStringIfNotNull(jsonObject, FIELD_VERIFIED_NAME, mVerifiedName); putStringIfNotNull(jsonObject, FIELD_VERIFIED_PHONE, mVerifiedPhone); } catch (JSONException ignored) { } return jsonObject; } SourceOwner(
            Address address,
            String email,
            String name,
            String phone,
            Address verifiedAddress,
            String verifiedEmail,
            String verifiedName,
            String verifiedPhone); }
SourceOwner extends StripeJsonModel { @NonNull @Override public JSONObject toJson() { JSONObject jsonObject = new JSONObject(); JSONObject jsonAddressObject = mAddress == null ? null : mAddress.toJson(); JSONObject jsonVerifiedAddressObject = mVerifiedAddress == null ? null : mVerifiedAddress.toJson(); try { if (jsonAddressObject != null && jsonAddressObject.length() > 0) { jsonObject.put(FIELD_ADDRESS, jsonAddressObject); } putStringIfNotNull(jsonObject, FIELD_EMAIL, mEmail); putStringIfNotNull(jsonObject, FIELD_NAME, mName); putStringIfNotNull(jsonObject, FIELD_PHONE, mPhone); if (jsonVerifiedAddressObject != null && jsonVerifiedAddressObject.length() > 0) { jsonObject.put(FIELD_VERIFIED_ADDRESS, jsonVerifiedAddressObject); } putStringIfNotNull(jsonObject, FIELD_VERIFIED_EMAIL, mVerifiedEmail); putStringIfNotNull(jsonObject, FIELD_VERIFIED_NAME, mVerifiedName); putStringIfNotNull(jsonObject, FIELD_VERIFIED_PHONE, mVerifiedPhone); } catch (JSONException ignored) { } return jsonObject; } SourceOwner(
            Address address,
            String email,
            String name,
            String phone,
            Address verifiedAddress,
            String verifiedEmail,
            String verifiedName,
            String verifiedPhone); Address getAddress(); String getEmail(); String getName(); String getPhone(); Address getVerifiedAddress(); String getVerifiedEmail(); String getVerifiedName(); String getVerifiedPhone(); @NonNull @Override Map<String, Object> toMap(); @NonNull @Override JSONObject toJson(); @Nullable static SourceOwner fromString(@Nullable String jsonString); @Nullable static SourceOwner fromJson(@Nullable JSONObject jsonObject); }
SourceOwner extends StripeJsonModel { @NonNull @Override public JSONObject toJson() { JSONObject jsonObject = new JSONObject(); JSONObject jsonAddressObject = mAddress == null ? null : mAddress.toJson(); JSONObject jsonVerifiedAddressObject = mVerifiedAddress == null ? null : mVerifiedAddress.toJson(); try { if (jsonAddressObject != null && jsonAddressObject.length() > 0) { jsonObject.put(FIELD_ADDRESS, jsonAddressObject); } putStringIfNotNull(jsonObject, FIELD_EMAIL, mEmail); putStringIfNotNull(jsonObject, FIELD_NAME, mName); putStringIfNotNull(jsonObject, FIELD_PHONE, mPhone); if (jsonVerifiedAddressObject != null && jsonVerifiedAddressObject.length() > 0) { jsonObject.put(FIELD_VERIFIED_ADDRESS, jsonVerifiedAddressObject); } putStringIfNotNull(jsonObject, FIELD_VERIFIED_EMAIL, mVerifiedEmail); putStringIfNotNull(jsonObject, FIELD_VERIFIED_NAME, mVerifiedName); putStringIfNotNull(jsonObject, FIELD_VERIFIED_PHONE, mVerifiedPhone); } catch (JSONException ignored) { } return jsonObject; } SourceOwner(
            Address address,
            String email,
            String name,
            String phone,
            Address verifiedAddress,
            String verifiedEmail,
            String verifiedName,
            String verifiedPhone); Address getAddress(); String getEmail(); String getName(); String getPhone(); Address getVerifiedAddress(); String getVerifiedEmail(); String getVerifiedName(); String getVerifiedPhone(); @NonNull @Override Map<String, Object> toMap(); @NonNull @Override JSONObject toJson(); @Nullable static SourceOwner fromString(@Nullable String jsonString); @Nullable static SourceOwner fromJson(@Nullable JSONObject jsonObject);  }