use of com.squareup.wire.schema.EnclosingType in project wire by square.
the class JavaGenerator method generateEnclosingType.
private TypeSpec generateEnclosingType(EnclosingType type) {
ClassName javaType = (ClassName) typeName(type.type());
TypeSpec.Builder builder = TypeSpec.classBuilder(javaType.simpleName()).addModifiers(PUBLIC, FINAL);
if (javaType.enclosingClassName() != null) {
builder.addModifiers(STATIC);
}
String documentation = type.documentation();
if (!documentation.isEmpty()) {
documentation += "\n\n<p>";
}
documentation += "<b>NOTE:</b> This type only exists to maintain class structure" + " for its nested types and is not an actual message.\n";
builder.addJavadoc(documentation);
builder.addMethod(MethodSpec.constructorBuilder().addModifiers(PRIVATE).addStatement("throw new $T()", AssertionError.class).build());
for (Type nestedType : type.nestedTypes()) {
builder.addType(generateType(nestedType));
}
return builder.build();
}
Aggregations