Skip to content

Commit

Permalink
make generated constructor private
Browse files Browse the repository at this point in the history
  • Loading branch information
h908714124 committed Apr 26, 2024
1 parent 02fc634 commit efa3afb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 2 additions & 0 deletions compiler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ dependencies {
shadow(jbock)
compileOnly(simple_component)
annotationProcessor('io.github.jbock-java:simple-component-compiler:1.024')
testRuntimeOnly('org.junit.platform:junit-platform-launcher')
testImplementation('io.github.jbock-java:compile-testing:0.19.12')
testImplementation('org.junit.jupiter:junit-jupiter:5.10.2')
testImplementation('org.mockito:mockito-core:5.11.0')
Expand All @@ -68,6 +69,7 @@ jar {

test {
useJUnitPlatform()
jvmArgs('-Xshare:off')
testLogging {
events('failed')
}
Expand Down
5 changes: 1 addition & 4 deletions compiler/src/main/java/net/jbock/writing/ParserClass.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.jbock.writing;

import io.jbock.javapoet.AnnotationSpec;
import io.jbock.javapoet.MethodSpec;
import io.jbock.javapoet.TypeSpec;
import io.jbock.simple.Inject;
Expand Down Expand Up @@ -62,9 +61,7 @@ TypeSpec define() {

spec.addMethod(createModelMethod.get());
Modifier[] modifiers = sourceElement().accessModifiers().toArray(new Modifier[0]);
spec.addMethod(MethodSpec.constructorBuilder().addModifiers(modifiers)
.addJavadoc("Constructor is deprecated, use the static methods instead.")
.addAnnotation(AnnotationSpec.builder(Deprecated.class).addMember("forRemoval", "true").build())
spec.addMethod(MethodSpec.constructorBuilder().addModifiers(Modifier.PRIVATE)
.build());

return spec.addOriginatingElement(sourceElement().element())
Expand Down

0 comments on commit efa3afb

Please sign in to comment.