diff --git a/easy-rules-core/src/main/java/org/jeasy/rules/api/Rules.java b/easy-rules-core/src/main/java/org/jeasy/rules/api/Rules.java index 4b73878..0936ef8 100644 --- a/easy-rules-core/src/main/java/org/jeasy/rules/api/Rules.java +++ b/easy-rules-core/src/main/java/org/jeasy/rules/api/Rules.java @@ -91,10 +91,10 @@ public class Rules implements Iterable { * * @param ruleName the name of the rule to unregister */ - public void unregister(final String ruleName){ + public void unregister(final String ruleName) { Objects.requireNonNull(ruleName); Rule rule = findRuleByName(ruleName); - if(rule != null) { + if (rule != null) { unregister(rule); } } @@ -120,7 +120,7 @@ public class Rules implements Iterable { return rules.iterator(); } - private Rule findRuleByName(String ruleName){ + private Rule findRuleByName(String ruleName) { return rules.stream() .filter(rule -> rule.getName().equalsIgnoreCase(ruleName)) .findFirst() diff --git a/easy-rules-core/src/main/java/org/jeasy/rules/core/InferenceRulesEngine.java b/easy-rules-core/src/main/java/org/jeasy/rules/core/InferenceRulesEngine.java index 8838cb9..282e0d7 100644 --- a/easy-rules-core/src/main/java/org/jeasy/rules/core/InferenceRulesEngine.java +++ b/easy-rules-core/src/main/java/org/jeasy/rules/core/InferenceRulesEngine.java @@ -67,7 +67,7 @@ public final class InferenceRulesEngine extends AbstractRulesEngine { do { LOGGER.debug("Selecting candidate rules based on the following facts: {}", facts); selectedRules = selectCandidates(rules, facts); - if(!selectedRules.isEmpty()) { + if (!selectedRules.isEmpty()) { delegate.fire(new Rules(selectedRules), facts); } else { LOGGER.debug("No candidate rules found for facts: {}", facts); 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 de6efa4..6181072 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 @@ -119,19 +119,19 @@ class RuleDefinitionValidator { private boolean validParameters(final Method method) { int notAnnotatedParameterCount = 0; Annotation[][] parameterAnnotations = method.getParameterAnnotations(); - for(Annotation[] annotations : parameterAnnotations){ - if(annotations.length == 0){ + 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)){ + for (Annotation annotation : annotations) { + if (!annotation.annotationType().equals(Fact.class)) { return false; } } } } - if(notAnnotatedParameterCount > 1){ + if (notAnnotatedParameterCount > 1) { return false; } if (notAnnotatedParameterCount == 1) { diff --git a/easy-rules-core/src/main/java/org/jeasy/rules/core/Utils.java b/easy-rules-core/src/main/java/org/jeasy/rules/core/Utils.java index 87c491b..c3ab7e5 100644 --- a/easy-rules-core/src/main/java/org/jeasy/rules/core/Utils.java +++ b/easy-rules-core/src/main/java/org/jeasy/rules/core/Utils.java @@ -27,12 +27,9 @@ import java.lang.annotation.Annotation; final class Utils { - private Utils() { - - } + private Utils() { } static A findAnnotation(final Class targetAnnotation, final Class annotatedType) { - A foundAnnotation = annotatedType.getAnnotation(targetAnnotation); if (foundAnnotation == null) { for (Annotation annotation : annotatedType.getAnnotations()) { diff --git a/easy-rules-core/src/test/java/org/jeasy/rules/core/RuleDefinitionValidatorTest.java b/easy-rules-core/src/test/java/org/jeasy/rules/core/RuleDefinitionValidatorTest.java index a407944..33755ff 100644 --- a/easy-rules-core/src/test/java/org/jeasy/rules/core/RuleDefinitionValidatorTest.java +++ b/easy-rules-core/src/test/java/org/jeasy/rules/core/RuleDefinitionValidatorTest.java @@ -34,7 +34,7 @@ public class RuleDefinitionValidatorTest { private RuleDefinitionValidator ruleDefinitionValidator; @Before - public void setup(){ + public void setup() { ruleDefinitionValidator = new RuleDefinitionValidator(); } diff --git a/easy-rules-support/src/main/java/org/jeasy/rules/support/AbstractRuleDefinitionReader.java b/easy-rules-support/src/main/java/org/jeasy/rules/support/AbstractRuleDefinitionReader.java index f3a3cf8..eb0183f 100644 --- a/easy-rules-support/src/main/java/org/jeasy/rules/support/AbstractRuleDefinitionReader.java +++ b/easy-rules-support/src/main/java/org/jeasy/rules/support/AbstractRuleDefinitionReader.java @@ -94,7 +94,7 @@ public abstract class AbstractRuleDefinitionReader implements RuleDefinitionRead throw new IllegalArgumentException("Composite rules must have composing rules specified"); } else if (composingRules != null) { List composingRuleDefinitions = new ArrayList<>(); - for (Object rule : composingRules){ + for (Object rule : composingRules) { Map composingRuleMap = (Map) rule; composingRuleDefinitions.add(createRuleDefinition(composingRuleMap)); } diff --git a/easy-rules-tutorials/src/main/java/org/jeasy/rules/tutorials/fizzbuzz/FizzBuzz.java b/easy-rules-tutorials/src/main/java/org/jeasy/rules/tutorials/fizzbuzz/FizzBuzz.java index 6ff8fa8..31c1d2d 100644 --- a/easy-rules-tutorials/src/main/java/org/jeasy/rules/tutorials/fizzbuzz/FizzBuzz.java +++ b/easy-rules-tutorials/src/main/java/org/jeasy/rules/tutorials/fizzbuzz/FizzBuzz.java @@ -28,7 +28,7 @@ package org.jeasy.rules.tutorials.fizzbuzz; */ public class FizzBuzz { // Everything in Java is a class public static void main(String[] args) { // Every program must have main() - for(int i = 1; i <= 100; i++) { // count from 1 to 100 + for (int i = 1; i <= 100; i++) { // count from 1 to 100 if (((i % 5) == 0) && ((i % 7) == 0)) // A multiple of both? System.out.print("fizzbuzz"); else if ((i % 5) == 0) System.out.print("fizz"); // else a multiple of 5?