package io.trustbuilder.mfa.android.demoapp.utils;

import java.util.List;
import java.util.stream.Collectors;

import io.trustbuilder.mfa.lib.definition.CredTypeEnum;
import io.trustbuilder.mfa.lib.usecase.definition.CredentialProvider;

public class CredentialProviderHandler {

    public CredentialProvider resolveCredentialProviderFromList(List<CredentialProvider> credentialProviders) {
        List<CredentialProvider> bioOnly = credentialProviders.stream().filter(credentialProvider -> credentialProvider.getCredType() == CredTypeEnum.BIO).collect(Collectors.toList());
        if (!bioOnly.isEmpty()) {
            return bioOnly.get(0);
        } else {
            return credentialProviders.get(0);
        }
    }
}
