use of com.fasterxml.jackson.annotation.JsonProperty in project Krill by KorAP.
the class Match method getSnippetHTML.
@JsonProperty("snippet")
public String getSnippetHTML() {
if (!this._processHighlight())
return null;
if (this.processed && this.snippetHTML != null)
return this.snippetHTML;
if (DEBUG)
log.trace("Create HTML Snippet");
StringBuilder sb = new StringBuilder();
StringBuilder rightContext = new StringBuilder();
// Remember ids already defined to
// have joined elements
HashSet<String> joins = new HashSet<>(100);
// Snippet stack sizes
short start = (short) 0;
short end = this.snippetArray.size();
// Create context
sb.append("<span class=\"context-left\">");
if (this.startMore)
sb.append("<span class=\"more\"></span>");
// Set levels for highlights
FixedBitSet level = new FixedBitSet(255);
level.set(0, 255);
byte[] levelCache = new byte[255];
HighlightCombinatorElement elem;
end--;
if (end > 0) {
// First element of sorted array
elem = this.snippetArray.getFirst();
// First element is textual
if (elem.type == 0) {
sb.append(elem.toHTML(this, level, levelCache, joins));
// Move start position
start++;
}
;
sb.append("</span>");
// Last element of sorted array
elem = this.snippetArray.getLast();
// Create right context, if there is any
rightContext.append("<span class=\"context-right\">");
// Last element is textual
if (elem != null && elem.type == 0) {
rightContext.append(elem.toHTML(this, level, levelCache, joins));
// decrement end
end--;
}
;
}
;
if (this.endMore)
rightContext.append("<span class=\"more\"></span>");
rightContext.append("</span>");
// Iterate through all remaining elements
sb.append("<span class=\"match\">");
for (short i = start; i <= end; i++) {
elem = this.snippetArray.get(i);
// UNTESTED
if (elem != null) {
String elemString = elem.toHTML(this, level, levelCache, joins);
if (DEBUG) {
log.trace("Add node {}", elemString);
}
;
sb.append(elemString);
}
}
;
sb.append("</span>");
sb.append(rightContext);
return (this.snippetHTML = sb.toString());
}
use of com.fasterxml.jackson.annotation.JsonProperty in project candlepin by candlepin.
the class CandlepinSwaggerModelConverter method parseProperty.
private void parseProperty(ModelConverterContext context, boolean isNested, final BeanDescription beanDesc, Set<String> propertiesToIgnore, List<Property> props, BeanPropertyDefinition propDef) {
Property property = null;
String propName = propDef.getName();
Annotation[] annotations = null;
propName = getPropName(propDef, propName);
PropertyMetadata md = propDef.getMetadata();
boolean hasSetter = false, hasGetter = false;
if (propDef.getSetter() == null) {
hasSetter = false;
} else {
hasSetter = true;
}
if (propDef.getGetter() != null) {
JsonProperty pd = propDef.getGetter().getAnnotation(JsonProperty.class);
if (pd != null) {
hasGetter = true;
}
}
Boolean isReadOnly = null;
if (!hasSetter & hasGetter) {
isReadOnly = Boolean.TRUE;
} else {
isReadOnly = Boolean.FALSE;
}
final AnnotatedMember member = propDef.getPrimaryMember();
if (member != null && !propertiesToIgnore.contains(propName) && /**
* If the owning type is nested than we should include only those
* fields that have the Hateoas annotation.
*/
!(isNested && !member.hasAnnotation(HateoasInclude.class))) {
List<Annotation> annotationList = new ArrayList<>();
for (Annotation a : member.annotations()) {
annotationList.add(a);
}
annotations = annotationList.toArray(new Annotation[annotationList.size()]);
ApiModelProperty mp = member.getAnnotation(ApiModelProperty.class);
if (mp != null && mp.readOnly()) {
isReadOnly = mp.readOnly();
}
Type nested = null;
JavaType propType = member.getType(beanDesc.bindingsForBeanType());
JsonFilter jsonFilter = propType.getRawClass().getAnnotation(JsonFilter.class);
/**
* At this point the propType is a type of some nested field of the
* type that is being processed. The condition checks if this
* particular type should have Hateoas serialization enabled. In
* other words, if we should create a new Nested* model.
*/
if (jsonFilter != null && (jsonFilter.value().equals("ConsumerFilter") || jsonFilter.value().equals("EntitlementFilter") || jsonFilter.value().equals("OwnerFilter") || jsonFilter.value().equals("GuestFilter"))) {
if (!nestedJavaTypes.containsKey(propType)) {
nestedJavaTypes.put(propType, new NestedComplexType(propType));
}
nested = nestedJavaTypes.get(propType);
} else {
nested = propType;
}
// allow override of name from annotation
if (mp != null && !mp.name().isEmpty()) {
propName = mp.name();
}
if (mp != null && !mp.dataType().isEmpty()) {
property = resolveApiAnnotated(context, property, annotations, mp, propType);
}
// no property from override, construct from propType
if (property == null) {
if (mp != null && StringUtils.isNotEmpty(mp.reference())) {
property = new RefProperty(mp.reference());
} else if (member.getAnnotation(JsonIdentityInfo.class) != null) {
property = GeneratorWrapper.processJsonIdentity(propType, context, pMapper, member.getAnnotation(JsonIdentityInfo.class), member.getAnnotation(JsonIdentityReference.class));
}
if (property == null) {
property = context.resolveProperty(nested, annotations);
}
}
if (property != null) {
addMetadataToProperty(property, propName, md, isReadOnly, member, mp);
applyBeanValidatorAnnotations(property, annotations);
props.add(property);
}
}
}
use of com.fasterxml.jackson.annotation.JsonProperty in project phoenicis by PhoenicisOrg.
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 com.fasterxml.jackson.annotation.JsonProperty in project pinpoint by naver.
the class TransactionInfoViewModel method getApplicationMapData.
@JsonProperty("applicationMapData")
public Map<String, List<Object>> getApplicationMapData() {
Map<String, List<Object>> result = new HashMap<String, List<Object>>();
if (timeHistogramFormat == TimeHistogramFormat.V2) {
for (Node node : nodes) {
node.setTimeHistogramFormat(timeHistogramFormat);
}
for (Link link : links) {
link.setTimeHistogramFormat(timeHistogramFormat);
}
}
List<Object> nodeDataArray = new ArrayList<>(nodes);
result.put("nodeDataArray", nodeDataArray);
List<Object> linkDataArray = new ArrayList<>(links);
result.put("linkDataArray", linkDataArray);
return result;
}
use of com.fasterxml.jackson.annotation.JsonProperty in project chassis by Kixeye.
the class ConstructorParameterModelProperty method getModelProperties.
/**
* Creates a collection of ConstructorParameterModelProperty objects from the arguments of the given ResolvedConstructor.
* Only args annotated with @JsonProperty are included. Scala Case Classes are a special case and do not require the annotation.
*
* @param resolvedConstructor the constructor to get
* @param alternateTypeProvider for resolving alternative types for the found arguments
* @return the collection of ConstructorParameterModelProperty objects
*/
public static ImmutableList<ConstructorParameterModelProperty> getModelProperties(ResolvedConstructor resolvedConstructor, AlternateTypeProvider alternateTypeProvider) {
Builder<ConstructorParameterModelProperty> listBuilder = new Builder<>();
if (resolvedConstructor.getRawMember().getAnnotation(JsonCreator.class) != null || scala.Product.class.isAssignableFrom(resolvedConstructor.getDeclaringType().getErasedType())) {
// constructor for normal classes must be annotated with @JsonCreator. Scala Case Classes are a special case
for (int i = 0; i < resolvedConstructor.getArgumentCount(); i++) {
AnnotationMap annotationMap = annotationMap(resolvedConstructor.getRawMember().getParameterAnnotations()[i]);
ResolvedType parameterType = resolvedConstructor.getArgumentType(i);
if (annotationMap.get(JsonProperty.class) != null) {
listBuilder.add(new ConstructorParameterModelProperty(parameterType, alternateTypeProvider, annotationMap));
}
}
}
return listBuilder.build();
}
Aggregations