ern-api-gen
Version:
Electrode Native API generator
91 lines • 3.57 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const javaUtil_1 = require("../java/javaUtil");
const StringUtils_1 = require("../java/StringUtils");
function splitCommaSeparatedList(input) {
const results = [];
if (StringUtils_1.isNotEmpty(input)) {
for (const value of input.split(',')) {
if (StringUtils_1.isNotEmpty(value)) {
results.push(value);
}
}
}
return results;
}
exports.splitCommaSeparatedList = splitCommaSeparatedList;
function parseCommaSeparatedTuples(input) {
const results = [];
for (const tuple of splitCommaSeparatedList(input)) {
const [name, value] = tuple.split('=', 2);
if (name != null && value != null) {
results.push([name, value]);
}
}
return results;
}
exports.parseCommaSeparatedTuples = parseCommaSeparatedTuples;
/**
* Contains shared logic for applying key-value pairs and CSV strings
* to specific settings in CodegenConfigurator.
*
* <p>
* This class exists to facilitate testing. These methods could be applied
* to CodegenConfigurator, but this complicates things when mocking CodegenConfigurator.
* </p>
*/
function applySystemPropertiesKvp(systemProperties, configurator) {
for (const [key, value] of createMapFromKeyValuePairs(systemProperties)) {
configurator.addSystemProperty(key, value);
}
}
exports.applySystemPropertiesKvp = applySystemPropertiesKvp;
function applyInstantiationTypesKvp(instantiationTypes, configurator) {
for (const [key, value] of createMapFromKeyValuePairs(instantiationTypes)) {
configurator.addInstantiationType(key, value);
}
}
exports.applyInstantiationTypesKvp = applyInstantiationTypesKvp;
function applyImportMappingsKvp(importMappings, configurator) {
for (const [key, value] of createMapFromKeyValuePairs(importMappings)) {
configurator.addImportMapping(key, value);
}
}
exports.applyImportMappingsKvp = applyImportMappingsKvp;
function applyTypeMappingsKvp(typeMappings, configurator) {
for (const [key, value] of createMapFromKeyValuePairs(typeMappings)) {
configurator.addTypeMapping(key, value);
}
}
exports.applyTypeMappingsKvp = applyTypeMappingsKvp;
function applyAdditionalPropertiesKvp(additionalProperties, configurator) {
for (const [key, value] of createMapFromKeyValuePairs(additionalProperties)) {
configurator.addAdditionalProperty(key, value);
}
}
exports.applyAdditionalPropertiesKvp = applyAdditionalPropertiesKvp;
function applyLanguageSpecificPrimitivesCsv(languageSpecificPrimitives, configurator) {
for (const item of createSetFromCsvList(languageSpecificPrimitives)) {
configurator.addLanguageSpecificPrimitive(item);
}
}
exports.applyLanguageSpecificPrimitivesCsv = applyLanguageSpecificPrimitivesCsv;
function createSetFromCsvList(csvProperty) {
return javaUtil_1.newHashSet(...splitCommaSeparatedList(csvProperty));
}
exports.createSetFromCsvList = createSetFromCsvList;
function createMapFromKeyValuePairs(commaSeparatedKVPairs) {
return javaUtil_1.newHashMap(...parseCommaSeparatedTuples(commaSeparatedKVPairs));
}
exports.createMapFromKeyValuePairs = createMapFromKeyValuePairs;
exports.default = {
applyAdditionalPropertiesKvp,
applyImportMappingsKvp,
applyInstantiationTypesKvp,
applyLanguageSpecificPrimitivesCsv,
applySystemPropertiesKvp,
applyTypeMappingsKvp,
createMapFromKeyValuePairs,
createSetFromCsvList,
};
//# sourceMappingURL=CodegenConfiguratorUtils.js.map