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."; builder.addJavadoc("$L\n", 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(); }
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"; } 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(); }
private TypeSpec generateEnclosingType(ProtoFile protoFile, 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(protoFile, nestedType)); } return builder.build(); }