Search in sources :

Example 1 with PropertyNamingStrategyBase

use of com.fasterxml.jackson.databind.PropertyNamingStrategy.PropertyNamingStrategyBase in project alien4cloud by alien4cloud.

the class AbstractMapper method quickMap.

/**
 * Map a field to be parsed as a scalar and mapped to a tosca field that use the same name based on LOWER_CASE_WITH_UNDERSCORES rather than CAMEL_CASE.
 *
 * @param fieldName The name of the field.
 */
public void quickMap(String fieldName) {
    int pathSeparatorLastIndex = fieldName.lastIndexOf(".");
    pathSeparatorLastIndex++;
    pathSeparatorLastIndex = pathSeparatorLastIndex > 0 ? pathSeparatorLastIndex : 0;
    String yamlFieldCamelCase = fieldName.substring(pathSeparatorLastIndex);
    String yamlField = ((PropertyNamingStrategyBase) PropertyNamingStrategy.SNAKE_CASE).translate(yamlFieldCamelCase);
    log.trace("Mapping yaml field {} to {} using basic ScalarParser", yamlField, fieldName);
    instance.getYamlToObjectMapping().put(yamlField, new MappingTarget(fieldName, scalarParser));
}
Also used : PropertyNamingStrategyBase(com.fasterxml.jackson.databind.PropertyNamingStrategy.PropertyNamingStrategyBase) MappingTarget(alien4cloud.tosca.parser.MappingTarget)

Example 2 with PropertyNamingStrategyBase

use of com.fasterxml.jackson.databind.PropertyNamingStrategy.PropertyNamingStrategyBase in project alien4cloud by alien4cloud.

the class AbstractMapper method quickMap.

/**
 * Map a field to be parsed with the given parser and mapped to a tosca field that use the same name based on LOWER_CASE_WITH_UNDERSCORES rather than
 * CAMEL_CASE.
 *
 * @param parser The parser to use to parse the field.
 * @param fieldName The name of the field to parse.
 */
public void quickMap(INodeParser<?> parser, String fieldName) {
    int pathSeparatorLastIndex = fieldName.lastIndexOf(".");
    pathSeparatorLastIndex++;
    pathSeparatorLastIndex = pathSeparatorLastIndex > 0 ? pathSeparatorLastIndex : 0;
    String yamlFieldCamelCase = fieldName.substring(pathSeparatorLastIndex);
    String yamlField = ((PropertyNamingStrategyBase) PropertyNamingStrategy.SNAKE_CASE).translate(yamlFieldCamelCase);
    log.info("Mapping yaml field {} to {} using basic ScalarParser", yamlField, fieldName);
    instance.getYamlToObjectMapping().put(yamlField, new MappingTarget(fieldName, parser));
}
Also used : PropertyNamingStrategyBase(com.fasterxml.jackson.databind.PropertyNamingStrategy.PropertyNamingStrategyBase) MappingTarget(alien4cloud.tosca.parser.MappingTarget)

Aggregations

MappingTarget (alien4cloud.tosca.parser.MappingTarget)2 PropertyNamingStrategyBase (com.fasterxml.jackson.databind.PropertyNamingStrategy.PropertyNamingStrategyBase)2