/** * Safely get description from a type with null checks * * @param type * The RAML TypeDeclaration to check * @return The description if defined or null if empty */ public static String getDescription(TypeDeclaration type) { if (type == null || type.description() == null) { return null; } else { return type.description().value(); } }
@Override public String description() { return type.description() == null ? null : type.description().value(); }
@Override public void onGetterMethodDeclaration(CurrentBuild currentBuild, final MethodSpec.Builder typeSpec, TypeDeclaration typeDeclaration) { if (typeDeclaration.description() != null) { typeSpec.addJavadoc("$L\n", typeDeclaration.description().value()); } javadocExamples(new JavadocAdder() { @Override public void addJavadoc(String format, Object... args) { typeSpec.addJavadoc(format, args); } }, typeDeclaration); }
@Override public MethodSpec.Builder getterBuilt(ObjectPluginContext objectPluginContext, TypeDeclaration declaration, final MethodSpec.Builder incoming, EventType eventType) { if (declaration.description() != null) { incoming.addJavadoc("$L\n", declaration.description().value()); } javadocExamples(new JavadocAdder() { @Override public void addJavadoc(String format, Object... args) { incoming.addJavadoc(format, args); } }, declaration); return incoming; }
@Override public TypeSpec.Builder onType(TypeContext context, final TypeSpec.Builder typeSpec, V10GType type, BuildPhase btype) { if (type.implementation().description() != null) { typeSpec.addJavadoc("$L\n", type.implementation().description().value()); } javadocExamples(new JavadocAdder() { @Override public void addJavadoc(String format, Object... args) { typeSpec.addJavadoc(format, args); } }, type.implementation()); return null; }
@Override public void onTypeDeclaration(CurrentBuild currentBuild, final TypeSpec.Builder typeSpec, V10GType type) { if (type.implementation().description() != null) { typeSpec.addJavadoc("$L\n", type.implementation().description().value()); } javadocExamples(new JavadocAdder() { @Override public void addJavadoc(String format, Object... args) { typeSpec.addJavadoc(format, args); } }, type.implementation()); }