Skip to content

Commit

Permalink
Create java-doc for builder factory methods
Browse files Browse the repository at this point in the history
Issue: #185
  • Loading branch information
muehmar committed Dec 6, 2023
1 parent 54e964d commit 63a324d
Show file tree
Hide file tree
Showing 4 changed files with 440 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,23 @@
import com.github.muehmar.gradle.openapi.generator.java.model.pojo.JavaObjectPojo;
import com.github.muehmar.gradle.openapi.generator.settings.PojoSettings;
import io.github.muehmar.codegenerator.Generator;
import io.github.muehmar.codegenerator.java.JavaDocGenerator;
import io.github.muehmar.codegenerator.writer.Writer;
import java.util.function.Function;

public class SafeBuilderGenerator implements Generator<JavaObjectPojo, PojoSettings> {
private static final String FACTORY_JAVA_DOC =
"Instantiates a new staged builder. Explicit properties have precedence over additional properties, i.e. an "
+ "additional property with the same name as an explicit property will be discarded if the explicit "
+ "property is set or if it gets set.";
private final Generator<JavaObjectPojo, PojoSettings> delegate;

public SafeBuilderGenerator(SafeBuilderVariant builderVariant) {
this.delegate =
factoryMethod(builderVariant, simpleBuilderMethodName(builderVariant))
JavaDocGenerator.<JavaObjectPojo, PojoSettings>ofJavaDocString(FACTORY_JAVA_DOC)
.append(factoryMethod(builderVariant, simpleBuilderMethodName(builderVariant)))
.appendSingleBlankLine()
.append(JavaDocGenerator.ofJavaDocString(FACTORY_JAVA_DOC))
.append(factoryMethod(builderVariant, pojoBuilderMethodName(builderVariant)))
.appendSingleBlankLine()
.append(allOfBuilderGenerator(builderVariant))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,22 @@ public class SampleObjectPojo1Dto {
}
}

/**
* Instantiates a new staged builder. Explicit properties have precedence over
* additional properties, i.e. an additional property with the same name as an
* explicit property will be discarded if the explicit property is set or if it
* gets set.
*/
public static FullPropertyBuilder0 fullBuilder() {
return new FullPropertyBuilder0(new Builder());
}

/**
* Instantiates a new staged builder. Explicit properties have precedence over
* additional properties, i.e. an additional property with the same name as an
* explicit property will be discarded if the explicit property is set or if it
* gets set.
*/
public static FullPropertyBuilder0 fullSampleObjectPojo1DtoBuilder() {
return new FullPropertyBuilder0(new Builder());
}
Expand Down Expand Up @@ -477,10 +489,22 @@ public class SampleObjectPojo1Dto {
}
}

/**
* Instantiates a new staged builder. Explicit properties have precedence over
* additional properties, i.e. an additional property with the same name as an
* explicit property will be discarded if the explicit property is set or if it
* gets set.
*/
public static PropertyBuilder0 builder() {
return new PropertyBuilder0(new Builder());
}

/**
* Instantiates a new staged builder. Explicit properties have precedence over
* additional properties, i.e. an additional property with the same name as an
* explicit property will be discarded if the explicit property is set or if it
* gets set.
*/
public static PropertyBuilder0 sampleObjectPojo1DtoBuilder() {
return new PropertyBuilder0(new Builder());
}
Expand Down
Loading

0 comments on commit 63a324d

Please sign in to comment.