protected String getInstanceUrl() { if (this.getCustomer() != null) { return String.format("%s/%s/sources/%s", classUrl(Customer.class), this.getCustomer(), this.getId()); } else if (this.getAccount() != null) { return String.format("%s/%s/external_accounts/%s", classUrl(Account.class), this.getAccount(), this.getId()); } else { return null; } } }