use of com.sun.javadoc.FieldDoc in project RESTdoclet by IG-Group.
the class DocTypeUtils method getFieldDoc.
/**
* Return the documentation for a field
*
* @param type
* @param attributeName
* @return
*/
private static String getFieldDoc(final Type type, final String attributeName, final String methodComment) {
LOG.debug("getFieldDoc " + type.simpleTypeName() + " - " + attributeName + " - " + methodComment);
String fieldComment = "";
if (type.asClassDoc() != null) {
for (FieldDoc field : type.asClassDoc().fields(false)) {
if (field.name().equalsIgnoreCase(attributeName)) {
fieldComment = field.commentText();
if (methodComment.length() > fieldComment.length()) {
fieldComment = methodComment;
}
// see if there are any validation
// constraints
AnnotationDesc[] annotations = field.annotations();
for (AnnotationDesc annotation : annotations) {
if (annotation.toString().contains("@javax.validation.constraints.")) {
String constraint = annotation.toString().replace("@javax.validation.constraints.", "");
fieldComment += "<br>[Rule: " + constraint + "]";
}
}
break;
}
}
}
return fieldComment;
}
use of com.sun.javadoc.FieldDoc in project RESTdoclet by IG-Group.
the class DocTypeUtils method getGetterNames.
/**
* Return a list of getter names
*
* @param type
* @return
*/
private static Collection<String> getGetterNames(final Type type) {
FieldDoc[] fields = type.asClassDoc().fields(false);
ArrayList<String> getterNames = new ArrayList<String>();
for (FieldDoc field : fields) {
if (!(field.isPublic() && field.isFinal() && StringUtils.equals(field.name(), field.name().toUpperCase()))) {
getterNames.add(GETTER_PREFIX + field.name().substring(0, 1).toUpperCase() + field.name().substring(1));
getterNames.add(IS_PREFIX + field.name().substring(0, 1).toUpperCase() + field.name().substring(1));
}
}
return getterNames;
}
use of com.sun.javadoc.FieldDoc in project Orchid by JavaEden.
the class ClassDocParser method getClassFields.
public JSONArray getClassFields(ClassDoc classDoc) {
JSONArray fields = new JSONArray();
for (FieldDoc fDoc : classDoc.fields()) {
JSONObject field = new JSONObject();
field.put("comment", commentParser.getCommentObject(fDoc));
field.put("annotations", annotationParser.getAnnotations(fDoc));
field.put("name", fDoc.name());
field.put("type", typeParser.getTypeObject(fDoc.type()));
fields.put(field);
}
return fields;
}
Aggregations