Search in sources :

Example 1 with DependencyField

use of org.ballerinalang.toml.model.fields.DependencyField in project ballerina by ballerina-lang.

the class ManifestBuildListener method createDependencyObject.

/**
 * Create dependency object and set the name.
 *
 * @param packageName pkg name of the dependency
 */
private void createDependencyObject(String packageName) {
    dependency = new Dependency();
    DependencyField dependencyField = DependencyField.NAME;
    if (dependencyField != null) {
        dependencyField.setValueTo(dependency, packageName);
    }
}
Also used : DependencyField(org.ballerinalang.toml.model.fields.DependencyField) Dependency(org.ballerinalang.toml.model.Dependency)

Example 2 with DependencyField

use of org.ballerinalang.toml.model.fields.DependencyField in project ballerina by ballerina-lang.

the class ManifestBuildListener method populateDependencyField.

/**
 * Populate dependency fields by iterating over the context object.
 *
 * @param ctx Inline table values
 */
private void populateDependencyField(TomlParser.InlineTableKeyvalsContext ctx) {
    for (TomlParser.InlineTableKeyvalsNonEmptyContext valueContext : ctx.inlineTableKeyvalsNonEmpty()) {
        String name = valueContext.key().getText();
        DependencyField dependencyField = DependencyField.valueOfLowerCase(name);
        if (dependencyField != null) {
            String value = valueContext.val().getText();
            if (valueContext.val().string() != null) {
                value = valueContext.val().string().basicString().basicStringValue().getText();
            }
            dependencyField.setValueTo(dependency, value);
        }
    }
}
Also used : DependencyField(org.ballerinalang.toml.model.fields.DependencyField) TomlParser(org.ballerinalang.toml.antlr4.TomlParser)

Aggregations

DependencyField (org.ballerinalang.toml.model.fields.DependencyField)2 TomlParser (org.ballerinalang.toml.antlr4.TomlParser)1 Dependency (org.ballerinalang.toml.model.Dependency)1