use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty in project raml-for-jax-rs by mulesoft-labs.
the class SimpleJacksonClassParser method forProperties.
private void forProperties(Class<?> classToParse, Map<String, PojoToRamlProperty> propertyMap) {
for (final Method method : classToParse.getDeclaredMethods()) {
if (!(method.getName().startsWith("get") || method.getName().startsWith("is"))) {
continue;
}
if (Modifier.isStatic(method.getModifiers())) {
continue;
}
JsonProperty elem = method.getAnnotation(JsonProperty.class);
if (elem != null) {
final String name = elem.value().equals("") ? buildName(method) : elem.value();
propertyMap.put(name, new PojoToRamlProperty() {
@Override
public <T extends Annotation> Optional<T> getAnnotation(Class<T> annotationType) {
return Optional.fromNullable(method.getAnnotation(annotationType));
}
@Override
public String name() {
return name;
}
@Override
public Type type() {
return method.getGenericReturnType();
}
});
}
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty in project autorest-clientruntime-for-java by Azure.
the class FlatteningSerializer method serializePartial.
private JsonNode serializePartial(Object value) {
if (value.getClass().isPrimitive() || value.getClass().isEnum() || value instanceof LocalDate || value instanceof DateTime || value instanceof String || value instanceof DateTimeRfc1123 || value instanceof Period) {
return mapper.valueToTree(value);
}
int mod = value.getClass().getModifiers();
if (Modifier.isFinal(mod) || Modifier.isStatic(mod)) {
return mapper.valueToTree(value);
}
if (value instanceof List<?>) {
ArrayNode node = new ArrayNode(mapper.getNodeFactory());
for (Object val : ((List<?>) value)) {
node.add(serializePartial(val));
}
return node;
}
if (value instanceof Map<?, ?>) {
ObjectNode node = new ObjectNode(mapper.getNodeFactory());
for (Map.Entry<?, ?> entry : ((Map<?, ?>) value).entrySet()) {
node.set((String) entry.getKey(), serializePartial(entry.getValue()));
}
return node;
}
ObjectNode res = new ObjectNode(mapper.getNodeFactory());
for (Field f : getAllDeclaredFields(value.getClass())) {
f.setAccessible(true);
String wireName = f.getName();
ObjectNode pointer = res;
JsonProperty property = f.getAnnotation(JsonProperty.class);
if (property != null && Access.WRITE_ONLY.equals(property.access())) {
continue;
}
if (property != null && !property.value().isEmpty()) {
wireName = f.getAnnotation(JsonProperty.class).value();
}
try {
Object propValue = f.get(value);
if (propValue != null) {
if (value.getClass().isAnnotationPresent(JsonFlatten.class) && wireName.matches(".+[^\\\\]\\..+")) {
String[] values = wireName.split("((?<!\\\\))\\.");
for (int i = 0; i < values.length; ++i) {
values[i] = values[i].replace("\\.", ".");
if (i == values.length - 1) {
break;
}
String val = values[i];
if (!pointer.has(val)) {
ObjectNode child = new ObjectNode(mapper.getNodeFactory());
pointer.set(val, child);
pointer = child;
} else {
pointer = (ObjectNode) pointer.get(val);
}
}
wireName = values[values.length - 1];
}
pointer.set(wireName, serializePartial(propValue));
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
return res;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty in project Krill by KorAP.
the class Match method getID.
/**
* Get match ID (for later retrieval).
*
* @see MatchIdentifier
*/
@Override
@JsonProperty("matchID")
public String getID() {
// Return identifier as given
if (this.mirrorIdentifier != null) {
return this.mirrorIdentifier;
}
;
// Identifier already created
if (this.identifier != null) {
return this.identifier;
}
;
// No, nada, nix
if (this.localDocID == -1)
return null;
MatchIdentifier id = this.getMatchIdentifier();
// Get prefix string corpus/doc
if (this.getTextSigle() != null) {
id.setTextSigle(this.getTextSigle());
} else // LEGACY
{
id.setCorpusID(this.getCorpusID());
id.setDocID(this.getDocID());
}
;
return (this.identifier = id.toString());
}
use of org.apache.flink.shaded.jackson2.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 org.apache.flink.shaded.jackson2.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