All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.undercouch.citeproc.DefaultAbbreviationProvider Maven / Gradle / Ivy

package de.undercouch.citeproc;

import de.undercouch.citeproc.csl.CSLItemData;

import java.util.HashMap;
import java.util.Map;

/**
 * Default implementation of {@link AbbreviationProvider}
 * @author Michel Kraemer
 */
public class DefaultAbbreviationProvider implements AbbreviationProvider {
    private final Map> abbrevs = new HashMap<>();

    public void addAbbreviation(String variable, String original, String abbreviation) {
        Map vm = abbrevs.computeIfAbsent(variable, v -> new HashMap<>());
        vm.put(original, abbreviation);
    }

    @Override
    public String getAbbreviation(String variable, String original, CSLItemData item) {
        Map vm = abbrevs.get(variable);
        if (vm != null) {
            return vm.get(original);
        }
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy