package lc.mecha.cred;

import java.util.HashMap;

public class CredentialBinder<T> {
    private Credential defaultCredential;
    private HashMap<T, Credential> particulars = new HashMap<>();

    public Credential getDefaultCredential() {
        return defaultCredential;
    }

    public void setDefaultCredential(Credential defaultCredential) {
        this.defaultCredential = defaultCredential;
    }

    public void putCredential(T key, Credential cred) {
        particulars.put(key, cred);
    }

    public Credential getCredential(T key) {
        Credential c = particulars.get(key);
        return c != null ? c : defaultCredential;
    }

}
