class PermittedAccountReferenceValidator {

    public ValidationResult validate(AisConsent aisConsent, String accountId, boolean withBalance) {
        AccountAccess accountAccess = aisConsent.getAspspAccountAccesses();
        List<AccountReference> accountReferences = withBalance
                                                       ? accountAccess.getBalances()
                                                       : accountAccess.getAccounts();

        return accountReferenceAccessValidator.validate(aisConsent, accountReferences, accountId, aisConsent.getAisConsentRequestType());
    }

}