@Override
    public ConsentDecision storeConsentDecision(final ConsentDecision decision) throws Throwable {
        val consent = getConsentDecisions()
            .stream()
            .anyMatch(d -> d.getId() == decision.getId());
        if (consent) {
            getConsentDecisions().remove(decision);
        } else {
            decision.setId(RandomUtils.nextInt());
        }
        getConsentDecisions().add(decision);
        return decision;
    }
This is {@link BaseConsentRepository}.

@author Misagh Moayyed
@since 5.2.0
support/cas-server-support-consent-core/src/main/java/org/apereo/cas/consent/BaseConsentRepository.java