use of org.apache.flink.shaded.jackson2.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 org.apache.flink.shaded.jackson2.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();
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty in project textdb by TextDB.
the class JsonSchemaHelper method getAdvancedOptionProperties.
public static List<String> getAdvancedOptionProperties(Class<? extends PredicateBase> predicateClass) {
ArrayList<String> advancedProperties = new ArrayList<>();
Constructor<?> constructor = getJsonCreatorConstructor(predicateClass);
for (Annotation[] annotations : Arrays.asList(constructor.getParameterAnnotations())) {
// find the @AdvancedOption annotation for each parameter
Optional<Annotation> findAdvancedOptionAnnotation = Arrays.asList(annotations).stream().filter(annotation -> annotation.annotationType().equals(AdvancedOption.class)).findAny();
if (!findAdvancedOptionAnnotation.isPresent()) {
continue;
}
AdvancedOption advancedOptionAnnotation = (AdvancedOption) findAdvancedOptionAnnotation.get();
// find the @JsonProperty annotation
Optional<Annotation> findJsonProperty = Arrays.asList(annotations).stream().filter(annotation -> annotation.annotationType().equals(JsonProperty.class)).findAny();
if (!findJsonProperty.isPresent()) {
continue;
}
JsonProperty jsonProperty = (JsonProperty) findJsonProperty.get();
if (advancedOptionAnnotation.isAdvancedOption()) {
advancedProperties.add(jsonProperty.value());
}
}
return advancedProperties;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty in project swagger-core by swagger-api.
the class SwaggerAnnotationIntrospector method hasRequiredMarker.
@Override
public Boolean hasRequiredMarker(AnnotatedMember m) {
XmlElement elem = m.getAnnotation(XmlElement.class);
if (elem != null) {
if (elem.required()) {
return true;
}
}
JsonProperty jsonProperty = m.getAnnotation(JsonProperty.class);
if (jsonProperty != null) {
if (jsonProperty.required()) {
return true;
}
}
Schema ann = m.getAnnotation(Schema.class);
if (ann != null) {
if (ann.required()) {
return ann.required();
}
}
ArraySchema arraySchema = m.getAnnotation(ArraySchema.class);
if (arraySchema != null) {
if (arraySchema.arraySchema().required()) {
return arraySchema.arraySchema().required();
}
if (arraySchema.schema().required()) {
return arraySchema.schema().required();
}
}
return null;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty in project hippo by NHS-digital-website.
the class CyberAlert method getBasePath.
@JsonProperty
public String getBasePath() {
if (getPublicallyAccessible() || getLimitedAccess()) {
final HstRequestContext context = RequestContextProvider.get();
if (context != null) {
// DW-1077 - compose this documetn base URL for REST API purposes
HttpServletRequest req = context.getServletRequest();
StringBuffer url = req.getRequestURL();
String base = url.substring(0, url.length() - req.getRequestURI().length() + req.getContextPath().length());
// remove basepath part ('content/documents/corporate-website')
// and compose full path
String pathSuffix = this.getPath().replace("/" + context.getSiteContentBasePath(), "");
// remove '/site/' if exists
return (base + pathSuffix).replace("/site/", "/");
}
}
return null;
}
Aggregations