use of com.fasterxml.jackson.annotation.JsonProperty in project OpenRefine by OpenRefine.
the class PreferenceStore method setEntries.
@JsonProperty("entries")
public void setEntries(JsonNode entries) {
Iterator<String> i = entries.fieldNames();
while (i.hasNext()) {
String key = i.next();
if (entries.get(key) != null) {
JsonNode o = entries.get(key);
Object loaded = loadObject(o);
if (loaded == null) {
if ("scripting.starred-expressions".contentEquals(key)) {
// HACK to work around preferences corruption
loaded = new TopList(10);
}
}
_prefs.put(key, loaded);
}
}
// internal puts don't count
dirty = false;
}
use of com.fasterxml.jackson.annotation.JsonProperty in project textdb by TextDB.
the class JsonSchemaHelper method getPropertyDefaultValues.
public static Map<String, Object> getPropertyDefaultValues(Class<? extends PredicateBase> predicateClass) {
HashMap<String, Object> defaultValueMap = new HashMap<>();
Constructor<?> constructor = getJsonCreatorConstructor(predicateClass);
// get all parameter types
Class<?>[] parameterTypes = constructor.getParameterTypes();
for (int i = 0; i < parameterTypes.length; i++) {
// find the @JsonProperty annotation for each parameter
Annotation[] annotations = constructor.getParameterAnnotations()[i];
Optional<Annotation> findJsonProperty = Arrays.asList(annotations).stream().filter(annotation -> annotation.annotationType().equals(JsonProperty.class)).findAny();
if (!findJsonProperty.isPresent()) {
continue;
}
// convert the defaultValue from the string to the parameter's type
JsonProperty jsonProperty = (JsonProperty) findJsonProperty.get();
if (!jsonProperty.defaultValue().trim().isEmpty()) {
defaultValueMap.put(jsonProperty.value(), objectMapper.convertValue(jsonProperty.defaultValue(), parameterTypes[i]));
}
}
return defaultValueMap;
}
use of com.fasterxml.jackson.annotation.JsonProperty in project textdb by TextDB.
the class JsonSchemaHelper method getRequiredProperties.
public static List<String> getRequiredProperties(Class<? extends PredicateBase> predicateClass) {
ArrayList<String> requiredProperties = new ArrayList<>();
Constructor<?> constructor = getJsonCreatorConstructor(predicateClass);
for (Annotation[] annotations : Arrays.asList(constructor.getParameterAnnotations())) {
// find the @JsonProperty annotation for each parameter
Optional<Annotation> findJsonProperty = Arrays.asList(annotations).stream().filter(annotation -> annotation.annotationType().equals(JsonProperty.class)).findAny();
if (!findJsonProperty.isPresent()) {
continue;
}
// add the required property to the list
JsonProperty jsonProperty = (JsonProperty) findJsonProperty.get();
if (jsonProperty.required()) {
requiredProperties.add(jsonProperty.value());
}
}
return requiredProperties;
}
use of com.fasterxml.jackson.annotation.JsonProperty in project hippo by NHS-digital-website.
the class Checklist method getListentriesJson.
@JsonProperty("listentries")
public List<String> getListentriesJson() {
List<HippoHtml> entries = getChildBeansByName("website:listentries", HippoHtml.class);
List<String> entriesStrings = new ArrayList<>();
for (HippoHtml entry : entries) {
if (entry != null) {
entriesStrings.add(entry.getContent());
} else {
entriesStrings.add((String) null);
}
}
return entriesStrings;
}
Aggregations