use of net.morimekta.providence.reflect.contained.CAnnotatedDescriptor in project providence by morimekta.
the class BaseMessageFormatter method appendMessageClass.
public void appendMessageClass(PMessageDescriptor<?, ?> descriptor) throws GeneratorException {
@SuppressWarnings("unchecked") JMessage<?> message = new JMessage(descriptor, helper);
BlockCommentBuilder classComment = null;
if (message.descriptor() instanceof CAnnotatedDescriptor) {
CAnnotatedDescriptor annotatedDescriptor = (CAnnotatedDescriptor) message.descriptor();
if (annotatedDescriptor.getDocumentation() != null) {
classComment = new BlockCommentBuilder(writer);
classComment.comment(annotatedDescriptor.getDocumentation());
}
String deprecatedReason = annotatedDescriptor.getAnnotationValue(ThriftAnnotation.DEPRECATED);
if (deprecatedReason != null && deprecatedReason.trim().length() > 0) {
if (classComment == null) {
classComment = new BlockCommentBuilder(writer);
} else {
classComment.newline();
}
classComment.deprecated_(deprecatedReason);
}
}
if (classComment != null) {
classComment.finish();
}
formatters.forEach(f -> f.appendClassAnnotations(message));
writer.formatln("%s %sclass %s", makeProtected ? "protected" : "public", inner ? "static " : "", getClassName(message)).begin().begin();
appendClassExtends(message);
writer.end();
Set<String> impl = new LinkedHashSet<>();
formatters.forEach(f -> impl.addAll(f.getExtraImplements(message)));
if (impl.size() > 0) {
writer.formatln(" implements ").begin(" ");
boolean first = true;
for (String i : impl) {
if (first) {
first = false;
} else {
writer.append(',').appendln();
}
writer.append(i);
}
writer.end();
}
writer.append(" {");
formatters.forEach(f -> f.appendConstants(message));
formatters.forEach(f -> f.appendFields(message));
formatters.forEach(f -> f.appendConstructors(message));
formatters.forEach(f -> f.appendMethods(message));
formatters.forEach(f -> f.appendExtraProperties(message));
writer.end().appendln('}');
}
Aggregations