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

org.pkl.thirdparty.commonmark.internal.Definitions Maven / Gradle / Ivy

Go to download

Fat Jar containing pkl-cli, pkl-codegen-java, pkl-codegen-kotlin, pkl-config-java, pkl-core, pkl-doc, and their shaded third-party dependencies.

There is a newer version: 0.27.1
Show newest version
package org.pkl.thirdparty.commonmark.internal;

import org.pkl.thirdparty.commonmark.node.DefinitionMap;

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

public class Definitions {

    private final Map, DefinitionMap> definitionsByType = new HashMap<>();

    public  void addDefinitions(DefinitionMap definitionMap) {
        var existingMap = getMap(definitionMap.getType());
        if (existingMap == null) {
            definitionsByType.put(definitionMap.getType(), definitionMap);
        } else {
            existingMap.addAll(definitionMap);
        }
    }

    public  V getDefinition(Class type, String label) {
        var definitionMap = getMap(type);
        if (definitionMap == null) {
            return null;
        }
        return definitionMap.get(label);
    }

    private  DefinitionMap getMap(Class type) {
        //noinspection unchecked
        return (DefinitionMap) definitionsByType.get(type);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy