|
|
@ -1,5 +1,5 @@
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Copyright 2012-2019 the original author or authors.
|
|
|
|
* Copyright 2012-2020 the original author or authors.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
@ -73,10 +73,10 @@ public class AnnotationsPropertySource extends EnumerablePropertySource<Class<?>
|
|
|
|
return properties;
|
|
|
|
return properties;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void collectProperties(String prefix, SkipPropertyMapping defaultSkip, MergedAnnotation<?> annotation,
|
|
|
|
private void collectProperties(String prefix, SkipPropertyMapping skip, MergedAnnotation<?> annotation,
|
|
|
|
Method attribute, Map<String, Object> properties) {
|
|
|
|
Method attribute, Map<String, Object> properties) {
|
|
|
|
MergedAnnotation<?> attributeMapping = MergedAnnotations.from(attribute).get(PropertyMapping.class);
|
|
|
|
MergedAnnotation<?> attributeMapping = MergedAnnotations.from(attribute).get(PropertyMapping.class);
|
|
|
|
SkipPropertyMapping skip = attributeMapping.getValue("skip", SkipPropertyMapping.class).orElse(defaultSkip);
|
|
|
|
skip = attributeMapping.getValue("skip", SkipPropertyMapping.class).orElse(skip);
|
|
|
|
if (skip == SkipPropertyMapping.YES) {
|
|
|
|
if (skip == SkipPropertyMapping.YES) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -90,7 +90,7 @@ public class AnnotationsPropertySource extends EnumerablePropertySource<Class<?>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String name = getName(prefix, attributeMapping, attribute);
|
|
|
|
String name = getName(prefix, attributeMapping, attribute);
|
|
|
|
putProperties(name, value.get(), properties);
|
|
|
|
putProperties(name, skip, value.get(), properties);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private String getName(String prefix, MergedAnnotation<?> attributeMapping, Method attribute) {
|
|
|
|
private String getName(String prefix, MergedAnnotation<?> attributeMapping, Method attribute) {
|
|
|
@ -118,11 +118,18 @@ public class AnnotationsPropertySource extends EnumerablePropertySource<Class<?>
|
|
|
|
return postfix;
|
|
|
|
return postfix;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void putProperties(String name, Object value, Map<String, Object> properties) {
|
|
|
|
private void putProperties(String name, SkipPropertyMapping defaultSkip, Object value,
|
|
|
|
|
|
|
|
Map<String, Object> properties) {
|
|
|
|
if (ObjectUtils.isArray(value)) {
|
|
|
|
if (ObjectUtils.isArray(value)) {
|
|
|
|
Object[] array = ObjectUtils.toObjectArray(value);
|
|
|
|
Object[] array = ObjectUtils.toObjectArray(value);
|
|
|
|
for (int i = 0; i < array.length; i++) {
|
|
|
|
for (int i = 0; i < array.length; i++) {
|
|
|
|
properties.put(name + "[" + i + "]", array[i]);
|
|
|
|
putProperties(name + "[" + i + "]", defaultSkip, array[i], properties);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (value instanceof MergedAnnotation<?>) {
|
|
|
|
|
|
|
|
MergedAnnotation<?> annotation = (MergedAnnotation<?>) value;
|
|
|
|
|
|
|
|
for (Method attribute : annotation.getType().getDeclaredMethods()) {
|
|
|
|
|
|
|
|
collectProperties(name, defaultSkip, (MergedAnnotation<?>) value, attribute, properties);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|