org.pkl.thirdparty.commonmark.internal.Definitions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pkl-tools Show documentation
Show all versions of pkl-tools Show documentation
Fat Jar containing pkl-cli, pkl-codegen-java, pkl-codegen-kotlin, pkl-config-java, pkl-core, pkl-doc, and their shaded third-party dependencies.
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