diff --git a/.project b/.project index 5146279..2280c00 100644 --- a/.project +++ b/.project @@ -20,4 +20,24 @@ org.eclipse.m2e.core.maven2Nature org.eclipse.jdt.core.javanature + + + 1683121120929 + + 10 + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-false-false-bin + + + + 1683121120939 + + 10 + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-false-false-out + + + diff --git a/pom.xml b/pom.xml index 77000e6..0fb28ae 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 fi.solita.utils meta-utils - 0.12.26 + 0.12.27 diff --git a/src/main/java/fi/solita/utils/meta/ForceMetadataGeneration.java b/src/main/java/fi/solita/utils/meta/ForceMetadataGeneration.java new file mode 100644 index 0000000..daea9eb --- /dev/null +++ b/src/main/java/fi/solita/utils/meta/ForceMetadataGeneration.java @@ -0,0 +1,16 @@ +package fi.solita.utils.meta; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Force specified metadata generation even if it is configured disabled globally + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface ForceMetadataGeneration { + boolean constructorsAsFunctions() default false; + boolean methodsAsFunctions() default false; +} diff --git a/src/main/java/fi/solita/utils/meta/generators/ConstructorsAsFunctions.java b/src/main/java/fi/solita/utils/meta/generators/ConstructorsAsFunctions.java index 48f544a..59a8afe 100644 --- a/src/main/java/fi/solita/utils/meta/generators/ConstructorsAsFunctions.java +++ b/src/main/java/fi/solita/utils/meta/generators/ConstructorsAsFunctions.java @@ -49,6 +49,8 @@ import fi.solita.utils.functional.Apply; import fi.solita.utils.functional.Function1; import fi.solita.utils.functional.Function3; +import fi.solita.utils.functional.Option; +import fi.solita.utils.meta.ForceMetadataGeneration; import fi.solita.utils.meta.Helpers; public class ConstructorsAsFunctions extends Generator { @@ -68,7 +70,7 @@ public static interface Options extends GeneratorOptions { @Override public Iterable apply(ProcessingEnvironment processingEnv, Options options, TypeElement source) { - if (!options.constructorsAsFunctionsEnabled()) { + if (!options.constructorsAsFunctionsEnabled() && (source.getAnnotation(ForceMetadataGeneration.class) == null || !source.getAnnotation(ForceMetadataGeneration.class).constructorsAsFunctions())) { return emptyList(); } diff --git a/src/main/java/fi/solita/utils/meta/generators/MethodsAsFunctions.java b/src/main/java/fi/solita/utils/meta/generators/MethodsAsFunctions.java index f72ff6a..4a1b400 100644 --- a/src/main/java/fi/solita/utils/meta/generators/MethodsAsFunctions.java +++ b/src/main/java/fi/solita/utils/meta/generators/MethodsAsFunctions.java @@ -69,6 +69,7 @@ import fi.solita.utils.functional.Pair; import fi.solita.utils.functional.Predicate; import fi.solita.utils.functional.Transformer; +import fi.solita.utils.meta.ForceMetadataGeneration; import fi.solita.utils.meta.Helpers; public class MethodsAsFunctions extends Generator { @@ -90,7 +91,7 @@ public static interface Options extends GeneratorOptions { @Override public Iterable apply(ProcessingEnvironment processingEnv, Options options, TypeElement source) { - if (!options.methodsAsFunctionsEnabled()) { + if (!options.methodsAsFunctionsEnabled() && (source.getAnnotation(ForceMetadataGeneration.class) == null || !source.getAnnotation(ForceMetadataGeneration.class).methodsAsFunctions())) { return emptyList(); }