use of com.fasterxml.jackson.annotation.JsonProperty in project raml-for-jax-rs by mulesoft-labs.
the class SimpleJacksonClassParser method forFields.
private void forFields(Class<?> classToParse, Map<String, PojoToRamlProperty> propertyMap) {
for (final Field field : classToParse.getDeclaredFields()) {
JsonProperty elem = field.getAnnotation(JsonProperty.class);
if (elem != null) {
final String name = elem.value().equals("") ? field.getName() : elem.value();
propertyMap.put(name, new PojoToRamlProperty() {
@Override
public <T extends Annotation> Optional<T> getAnnotation(Class<T> annotationType) {
return Optional.fromNullable(field.getAnnotation(annotationType));
}
@Override
public String name() {
return name;
}
@Override
public Type type() {
return field.getGenericType();
}
});
}
}
}
use of 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 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 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 com.fasterxml.jackson.annotation.JsonProperty in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityDetailsDto method getCharacteristics.
@JsonProperty("characteristics")
@JsonView({ CommonView.class })
public Map<String, Set<Object>> getCharacteristics() {
Map<String, Set<Object>> characMap = null;
if (fluxCharacteristics != null) {
characMap = Maps.newHashMap();
for (FluxCharacteristicsDto fluxCharacteristicsDto : fluxCharacteristics) {
Double calculatedValueMeasure = fluxCharacteristicsDto.getCalculatedValueMeasure();
add("calculatedValueMeasure", calculatedValueMeasure, characMap);
Double calculatedValueQuantity = fluxCharacteristicsDto.getCalculatedValueQuantity();
add("calculatedValueQuantity", calculatedValueQuantity, characMap);
String description = fluxCharacteristicsDto.getDescription();
add("description", description, characMap);
String descriptionLanguageId = fluxCharacteristicsDto.getDescriptionLanguageId();
add("descriptionLanguageId", descriptionLanguageId, characMap);
String typeCode = fluxCharacteristicsDto.getTypeCode();
add("typeCode", typeCode, characMap);
String typeCodeListId = fluxCharacteristicsDto.getTypeCodeListId();
add("typeCodeListId", typeCodeListId, characMap);
Date valueDateTime = fluxCharacteristicsDto.getValueDateTime();
add("valueDateTime", valueDateTime, characMap);
String valueIndicator = fluxCharacteristicsDto.getValueIndicator();
add("valueIndicator", valueIndicator, characMap);
Double valueMeasure = fluxCharacteristicsDto.getValueMeasure();
add("valueMeasure", valueMeasure, characMap);
String valueMeasureUnitCode = fluxCharacteristicsDto.getValueMeasureUnitCode();
add("valueMeasureUnitCode", valueMeasureUnitCode, characMap);
Double valueQuantity = fluxCharacteristicsDto.getValueQuantity();
add("valueQuantity", valueQuantity, characMap);
String valueQuantityCode = fluxCharacteristicsDto.getValueQuantityCode();
add("valueQuantityCode", valueQuantityCode, characMap);
String valueLanguageId = fluxCharacteristicsDto.getValueLanguageId();
add("valueLanguageId", valueLanguageId, characMap);
String valueCode = fluxCharacteristicsDto.getValueCode();
add("valueCode", valueCode, characMap);
}
}
return characMap;
}
Aggregations