diff --git a/easy-rules-core/pom.xml b/easy-rules-core/pom.xml
index b3a0faf5..1b88cdf6 100644
--- a/easy-rules-core/pom.xml
+++ b/easy-rules-core/pom.xml
@@ -77,6 +77,11 @@
mockito-core
test
+
+ com.google.code.findbugs
+ jsr305
+ test
+
diff --git a/easy-rules-core/src/main/java/org/jeasy/rules/core/RuleDefinitionValidator.java b/easy-rules-core/src/main/java/org/jeasy/rules/core/RuleDefinitionValidator.java
index 7511879c..fe34b899 100644
--- a/easy-rules-core/src/main/java/org/jeasy/rules/core/RuleDefinitionValidator.java
+++ b/easy-rules-core/src/main/java/org/jeasy/rules/core/RuleDefinitionValidator.java
@@ -30,7 +30,12 @@
import java.lang.reflect.Modifier;
import java.lang.reflect.Parameter;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
+
import org.jeasy.rules.annotation.Action;
import org.jeasy.rules.annotation.Condition;
import org.jeasy.rules.annotation.Fact;
@@ -117,20 +122,24 @@ private boolean isConditionMethodWellDefined(final Method method) {
&& validParameters(method);
}
+ private static final Set OTHER_ANNOTATIONS = Collections.singleton("javax.annotation.Nullable");
+
private boolean validParameters(final Method method) {
int notAnnotatedParameterCount = 0;
Annotation[][] parameterAnnotations = method.getParameterAnnotations();
for (Annotation[] annotations : parameterAnnotations) {
- if (annotations.length == 0) {
- notAnnotatedParameterCount += 1;
- } else {
- //Annotation types has to be Fact
- for (Annotation annotation : annotations) {
- if (!annotation.annotationType().equals(Fact.class)) {
- return false;
- }
+ boolean annotatedAsFact = false;
+ for (Annotation annotation : annotations) {
+ //Annotation types has to be Fact or another accepted annotation
+ if (annotation.annotationType().equals(Fact.class)) {
+ annotatedAsFact = true;
+ } else if (!OTHER_ANNOTATIONS.contains(annotation.annotationType().getCanonicalName())) {
+ return false;
}
}
+ if (!annotatedAsFact) {
+ notAnnotatedParameterCount += 1;
+ }
}
if (notAnnotatedParameterCount > 1) {
return false;
@@ -147,6 +156,15 @@ private boolean validParameters(final Method method) {
private Parameter getNotAnnotatedParameter(Method method) {
Parameter[] parameters = method.getParameters();
for (Parameter parameter : parameters) {
+ boolean hasAnnotation = false;
+ for (Annotation annotation : parameter.getAnnotations()) {
+ if (annotation.annotationType().equals(Fact.class)) {
+ hasAnnotation = true;
+ }
+ }
+ if (!hasAnnotation) {
+ return parameter;
+ }
if (parameter.getAnnotations().length == 0) {
return parameter;
}
diff --git a/easy-rules-core/src/main/java/org/jeasy/rules/core/RuleProxy.java b/easy-rules-core/src/main/java/org/jeasy/rules/core/RuleProxy.java
index 399ef8ff..437620e0 100644
--- a/easy-rules-core/src/main/java/org/jeasy/rules/core/RuleProxy.java
+++ b/easy-rules-core/src/main/java/org/jeasy/rules/core/RuleProxy.java
@@ -163,15 +163,23 @@ private List