use of com.fasterxml.jackson.annotation.JsonProperty in project jirm by agentgt.
the class SqlParameterDefinition method getSqlBeanParametersFromJsonCreatorConstructor.
private static Map<String, SqlParameterDefinition> getSqlBeanParametersFromJsonCreatorConstructor(Constructor<?> c, SqlObjectConfig config) {
Map<String, SqlParameterDefinition> parameters = new LinkedHashMap<String, SqlParameterDefinition>();
Annotation[][] aas = c.getParameterAnnotations();
Class<?>[] pts = c.getParameterTypes();
if (aas == null || aas.length == 0) {
return parameters;
}
for (int i = 0; i < aas.length; i++) {
Annotation[] as = aas[i];
Class<?> parameterType = pts[i];
for (int j = 0; j < as.length; j++) {
Annotation a = as[j];
if (JsonProperty.class.equals(a.annotationType())) {
JsonProperty p = (JsonProperty) a;
String value = p.value();
final SqlParameterDefinition definition = parameterDef(config, c.getDeclaringClass(), value, parameterType, i);
parameters.put(value, definition);
}
}
}
return parameters;
}
use of com.fasterxml.jackson.annotation.JsonProperty in project OpenRefine by OpenRefine.
the class FileProjectManager method loadProjects.
@JsonProperty("projectIDs")
protected void loadProjects(List<Long> projectIDs) {
for (Long id : projectIDs) {
File projectDir = getProjectDir(id);
ProjectMetadata metadata = ProjectMetadataUtilities.load(projectDir);
mergeEmptyUserMetadata(metadata);
_projectsMetadata.put(id, metadata);
if (metadata != null && metadata.getTags() != null) {
for (String tag : metadata.getTags()) {
if (_projectsTags.containsKey(tag)) {
_projectsTags.put(tag, _projectsTags.get(tag) + 1);
} else {
_projectsTags.put(tag, 1);
}
}
}
}
}
use of com.fasterxml.jackson.annotation.JsonProperty in project dhis2-core by dhis2.
the class ImportReport method getStats.
@JsonProperty
@JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public Stats getStats() {
Stats stats = new Stats();
typeReportMap.values().forEach(typeReport -> stats.merge(typeReport.getStats()));
return stats;
}
use of com.fasterxml.jackson.annotation.JsonProperty in project dhis2-core by dhis2.
the class JacksonPropertyIntrospector method collectProperties.
private static List<Property> collectProperties(Class<?> klass) {
boolean isPrimitiveOrWrapped = ClassUtils.isPrimitiveOrWrapper(klass);
if (isPrimitiveOrWrapped) {
return Collections.emptyList();
}
List<Field> fields = ReflectionUtils.findFields(klass, f -> f.isAnnotationPresent(JsonProperty.class));
List<Method> methods = ReflectionUtils.findMethods(klass, m -> AnnotationUtils.findAnnotation(m, JsonProperty.class) != null && m.getParameterTypes().length == 0);
Multimap<String, Method> multimap = ReflectionUtils.getMethodsMultimap(klass);
Map<String, Property> propertyMap = new HashMap<>();
for (var field : fields) {
Property property = new Property(klass, null, null);
property.setAnnotations(getAnnotations(field.getAnnotations()));
JsonProperty jsonProperty = field.getAnnotation(JsonProperty.class);
String fieldName = field.getName();
String name = StringUtils.isEmpty(requireNonNull(jsonProperty).value()) ? fieldName : jsonProperty.value();
property.setName(name);
property.setFieldName(fieldName);
property.setSetterMethod(ReflectionUtils.findSetterMethod(fieldName, klass));
property.setGetterMethod(ReflectionUtils.findGetterMethod(fieldName, klass));
property.setNamespace(trimToNull(jsonProperty.namespace()));
propertyMap.put(name, property);
}
for (var method : methods) {
JsonProperty jsonProperty = AnnotationUtils.findAnnotation(method, JsonProperty.class);
String fieldName = ReflectionUtils.getFieldName(method);
String name = StringUtils.isEmpty(requireNonNull(jsonProperty).value()) ? fieldName : jsonProperty.value();
if (propertyMap.containsKey(name)) {
continue;
}
Property property = new Property(klass, method, null);
property.setAnnotations(getAnnotations(method.getAnnotations()));
property.setName(name);
property.setFieldName(fieldName);
property.setNamespace(trimToNull(jsonProperty.namespace()));
propertyMap.put(name, property);
String setterName = "set" + capitalize(fieldName);
if (multimap.containsKey(setterName)) {
property.setSetterMethod(multimap.get(setterName).iterator().next());
}
propertyMap.put(name, property);
}
return new ArrayList<>(propertyMap.values());
}
use of com.fasterxml.jackson.annotation.JsonProperty in project POL-POM-5 by PlayOnLinux.
the class LocalisationHelper method fetchParameterName.
private String fetchParameterName(Parameter parameter) {
final JsonProperty jsonAnnotation = parameter.getAnnotation(JsonProperty.class);
final ParameterName parameterNameAnnotation = parameter.getAnnotation(ParameterName.class);
if (parameterNameAnnotation != null) {
return parameterNameAnnotation.value();
}
if (jsonAnnotation != null) {
return jsonAnnotation.value();
}
return parameter.getName();
}
Aggregations