PropertyGenerator Class — spring-boot Architecture
Architecture documentation for the PropertyGenerator class in AutoConfigureAnnotationProcessor.java from the spring-boot codebase.
Entity Profile
Source Code
core/spring-boot-autoconfigure-processor/src/main/java/org/springframework/boot/autoconfigureprocessor/AutoConfigureAnnotationProcessor.java lines 288–362
static final class PropertyGenerator {
private final String annotationPackage;
private final String propertyName;
private final boolean omitEmptyValues;
private final Map<String, ValueExtractor> valueExtractors;
private PropertyGenerator(String annotationPackage, String propertyName, boolean omitEmptyValues,
Map<String, ValueExtractor> valueExtractors) {
this.annotationPackage = annotationPackage;
this.propertyName = propertyName;
this.omitEmptyValues = omitEmptyValues;
this.valueExtractors = valueExtractors;
}
PropertyGenerator withAnnotation(ValueExtractor valueExtractor) {
return withAnnotation(this.propertyName, valueExtractor);
}
PropertyGenerator withAnnotation(String name, ValueExtractor ValueExtractor) {
Map<String, ValueExtractor> valueExtractors = new LinkedHashMap<>(this.valueExtractors);
valueExtractors.put(this.annotationPackage + "." + name, ValueExtractor);
return new PropertyGenerator(this.annotationPackage, this.propertyName, this.omitEmptyValues,
valueExtractors);
}
Set<String> getSupportedAnnotations() {
return this.valueExtractors.keySet();
}
ValueExtractor getValueExtractor(String annotation) {
return this.valueExtractors.get(annotation);
}
void applyToProperties(Map<String, String> properties, String className, List<Object> annotationValues) {
if (this.omitEmptyValues && annotationValues.isEmpty()) {
return;
}
mergeProperties(properties, className + "." + this.propertyName, toCommaDelimitedString(annotationValues));
}
private void mergeProperties(Map<String, String> properties, String key, String value) {
String existingKey = properties.get(key);
if (existingKey == null || existingKey.isEmpty()) {
properties.put(key, value);
}
else if (!value.isEmpty()) {
properties.put(key, existingKey + "," + value);
}
}
private String toCommaDelimitedString(List<Object> list) {
if (list.isEmpty()) {
return "";
}
StringBuilder result = new StringBuilder();
for (Object item : list) {
result.append((!result.isEmpty()) ? "," : "");
result.append(item);
}
return result.toString();
}
static PropertyGenerator of(String annotationPackage, String propertyName) {
return of(annotationPackage, propertyName, false);
}
static PropertyGenerator of(String annotationPackage, String propertyName, boolean omitEmptyValues) {
return new PropertyGenerator(annotationPackage, propertyName, omitEmptyValues, Collections.emptyMap());
}
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free