Java 类com.fasterxml.jackson.annotation.JsonPropertyDescription 实例源码

项目:GitHub    文件:Jackson2Annotator.java   
@Override
public void propertyField(JFieldVar field, JDefinedClass clazz, String propertyName, JsonNode propertyNode) {
    field.annotate(JsonProperty.class).param("value", propertyName);
    if (field.type().erasure().equals(field.type().owner().ref(Set.class))) {
        field.annotate(JsonDeserialize.class).param("as", LinkedHashSet.class);
    }

    if (propertyNode.has("javaJsonView")) {
        field.annotate(JsonView.class).param(
                "value", field.type().owner().ref(propertyNode.get("javaJsonView").asText()));
    }

    if (propertyNode.has("description")) {
        field.annotate(JsonPropertyDescription.class).param("value", propertyNode.get("description").asText());
    }
}
项目:GitHub    文件:AnnotationStyleIT.java   
@Test
public void annotationStyleJackson2ProducesJsonPropertyDescription() throws Exception {
    Class<?> generatedType = schemaRule.generateAndCompile("/schema/description/description.json", "com.example", config("annotationStyle", "jackson2")).loadClass("com.example.Description");

    Field field = generatedType.getDeclaredField("description");
    assertThat(field.getAnnotation(JsonPropertyDescription.class).value(), is("A description for this property"));
}
项目:mesh    文件:TableGenerator.java   
private void getInfoForClass(List<Map<String, String>> rows, Class<?> clazz, String prefix) throws Exception {
    Object instance = clazz.newInstance();
    Field[] fields = clazz.getDeclaredFields();
    for (Field field : fields) {
        field.setAccessible(true);
        String fieldName = field.getName();
        String description = null;
        boolean isRequired = false;
        Object defaultValue = null;
        try {
            defaultValue = field.get(instance);
        } catch (IllegalArgumentException e) {

        }
        for (Annotation annotation : field.getAnnotations()) {
            if (annotation instanceof JsonProperty) {
                JsonProperty propAnn = (JsonProperty) annotation;
                String name = propAnn.value();
                if (!StringUtils.isEmpty(name)) {
                    fieldName = name;
                }
                isRequired = propAnn.required();
            }
            if (annotation instanceof JsonPropertyDescription) {
                JsonPropertyDescription descAnn = (JsonPropertyDescription) annotation;
                description = descAnn.value();
            }
        }
        if (hasGenerateDocumentation(field)) {
            getInfoForClass(rows, field.getType(), fieldName);
        } else if (description != null) {
            Map<String, String> entries = new HashMap<>();
            if (prefix != null) {
                fieldName = prefix + "." + fieldName;
            }
            String type = field.getType().getSimpleName().toLowerCase();
            entries.put("key", fieldName);
            entries.put("description", description);
            entries.put("type", type.toLowerCase());
            entries.put("defaultValue", String.valueOf(defaultValue));
            entries.put("required", String.valueOf(isRequired));
            rows.add(entries);
        }
    }
}
项目:phenopacket-reference-implementation    文件:Entity.java   
@JsonProperty("id")
@JsonPropertyDescription("A unique identifier for the entity, can be either URI or CURIE")
@JsonldId
public String getId();
项目:phenopacket-reference-implementation    文件:Entity.java   
@JsonProperty("label")
@JsonPropertyDescription("A string that contains the preferred natural language term to denote the entity")
@JsonldProperty("http://www.w3.org/2000/01/rdf-schema#label")
public String getLabel();
项目:phenopacket-reference-implementation    文件:Association.java   
@JsonProperty("evidence")
@JsonPropertyDescription("Any Association can have any number of pieces of evidence attached")
public List<Evidence> getEvidence();
项目:bard    文件:DocParameter.java   
@JsonProperty(value = "schema")
@JsonPropertyDescription("The type of this param")
public JsonSchema getType() throws JsonMappingException {
    return Document.toJsonSchema(type);
}
项目:bard    文件:Response.java   
@JsonProperty(value = "schema")
@JsonPropertyDescription("The return type.")
public JsonSchema getReturn() throws JsonMappingException {
    return Document.toJsonSchema(returnType);
}
项目:mesh    文件:FieldSchema.java   
/**
 * Return the type of the field schema.
 * 
 * @return Field schema type
 */
@JsonProperty(required = true)
@JsonPropertyDescription("Type of the field.")
String getType();
项目:mesh    文件:FieldSchema.java   
/**
 * Return the label of the field schema.
 * 
 * @return Label
 */
@JsonProperty(required = false)
@JsonPropertyDescription("Label of the field.")
String getLabel();
项目:mesh    文件:FieldSchema.java   
/**
 * Return the name of the field schema.
 * 
 * @return Name
 */
@JsonProperty(required = true)
@JsonPropertyDescription("Name of the field.")
String getName();