use of io.micronaut.core.naming.conventions.StringConvention in project micronaut-core by micronaut-projects.
the class PropertySourcePropertyResolver method resolveSubProperties.
/**
* @param name The property name
* @param entries The entries
* @param conversionContext The conversion context
* @return The subproperties
*/
protected Properties resolveSubProperties(String name, Map<String, Object> entries, ArgumentConversionContext<?> conversionContext) {
// special handling for maps for resolving sub keys
Properties properties = new Properties();
AnnotationMetadata annotationMetadata = conversionContext.getAnnotationMetadata();
StringConvention keyConvention = annotationMetadata.enumValue(MapFormat.class, "keyFormat", StringConvention.class).orElse(null);
if (keyConvention == StringConvention.RAW) {
entries = resolveEntriesForKey(name, false, PropertyCatalog.RAW);
}
String prefix = name + '.';
entries.entrySet().stream().filter(map -> map.getKey().startsWith(prefix)).forEach(entry -> {
Object value = entry.getValue();
if (value != null) {
String key = entry.getKey().substring(prefix.length());
key = keyConvention != null ? keyConvention.format(key) : key;
properties.put(key, resolvePlaceHoldersIfNecessary(value.toString()));
}
});
return properties;
}
use of io.micronaut.core.naming.conventions.StringConvention in project micronaut-security by micronaut-projects.
the class InterceptUrlMapConverter method transform.
private Map<String, Object> transform(Map<String, Object> map) {
Map<String, Object> transformed = new HashMap<>();
StringConvention convention = StringConvention.HYPHENATED;
for (Map.Entry<String, Object> entry : map.entrySet()) {
transformed.put(convention.format(entry.getKey()), entry.getValue());
}
return transformed;
}
use of io.micronaut.core.naming.conventions.StringConvention in project micronaut-core by micronaut-projects.
the class PropertySourcePropertyResolver method resolveSubMap.
/**
* @param name The property name
* @param entries The entries
* @param conversionContext The conversion context
* @return The submap
*/
protected Map<String, Object> resolveSubMap(String name, Map<String, Object> entries, ArgumentConversionContext<?> conversionContext) {
// special handling for maps for resolving sub keys
AnnotationMetadata annotationMetadata = conversionContext.getAnnotationMetadata();
StringConvention keyConvention = annotationMetadata.enumValue(MapFormat.class, "keyFormat", StringConvention.class).orElse(null);
if (keyConvention == StringConvention.RAW) {
entries = resolveEntriesForKey(name, false, PropertyCatalog.RAW);
}
MapFormat.MapTransformation transformation = annotationMetadata.enumValue(MapFormat.class, "transformation", MapFormat.MapTransformation.class).orElse(MapFormat.MapTransformation.NESTED);
return resolveSubMap(name, entries, conversionContext, keyConvention, transformation);
}
Aggregations