Skip to content

Commit c3b0c05

Browse files
authored
Merge pull request #377 from powerunit/issue/#376
Issue #376 - Add support for disableGenerationOfFactory
2 parents 8cc6f83 + a281af1 commit c3b0c05

File tree

5 files changed

+54
-0
lines changed

5 files changed

+54
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package ch.powerunit.extensions.matchers.samples;
2+
3+
import ch.powerunit.extensions.matchers.ProvideMatchers;
4+
5+
@ProvideMatchers(disableGenerationOfFactory = true)
6+
public class Sample2 {
7+
private String field1;
8+
9+
public String getField1() {
10+
return field1;
11+
}
12+
13+
public void setField1(String field1) {
14+
this.field1 = field1;
15+
}
16+
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package ch.powerunit.extensions.matchers.samples;
2+
3+
import ch.powerunit.extensions.matchers.ProvideMatchers;
4+
5+
@ProvideMatchers(disableGenerationOfFactory = true)
6+
public class Sample2 {
7+
private String field1;
8+
9+
public String getField1() {
10+
return field1;
11+
}
12+
13+
public void setField1(String field1) {
14+
this.field1 = field1;
15+
}
16+
17+
}

src/main/java/ch/powerunit/extensions/matchers/ProvideMatchers.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,4 +344,12 @@
344344
* @since 0.1.0
345345
*/
346346
public static final String JSON_EXTENSION = "json-extension";
347+
348+
/**
349+
* May be used to disable generation of the factory.
350+
*
351+
* @return true to disable the generation of the factory
352+
* @since 0.4.0
353+
*/
354+
boolean disableGenerationOfFactory() default false;
347355
}

src/main/java/ch/powerunit/extensions/matchers/provideprocessor/ProvideMatchersAnnotationMirror.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,14 @@ public String[] extensions() {
6666
public ProvideMatchers getRealAnnotation() {
6767
return realAnnotation;
6868
}
69+
70+
/**
71+
*
72+
* @return is generation of factory disable
73+
* @since 0.4.0
74+
*/
75+
public boolean isDisableGenerationOfFactory() {
76+
return realAnnotation.disableGenerationOfFactory();
77+
}
6978

7079
}

src/main/java/ch/powerunit/extensions/matchers/provideprocessor/ProvidesMatchersAnnotatedElementMirror.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ public Collection<DSLMethod> process() {
102102
generatePrivateImplementation(), JOIN_DSL_METHOD.asString(tmp), POSTPROCESSOR_FORMAT,
103103
generateMetadata());
104104
output.flush();
105+
if (isDisableGenerationOfFactory() ) {
106+
return Collections.emptyList();
107+
}
105108
return tmp;
106109
}, e -> traceErrorAndDump(this, e, te));
107110
}

0 commit comments

Comments
 (0)