diff --git a/annotationprocessor/src/main/java/io/toolisticon/annotationprocessortoolkit/tools/fluentfilter/FluentElementFilter.java b/annotationprocessor/src/main/java/io/toolisticon/annotationprocessortoolkit/tools/fluentfilter/FluentElementFilter.java index a86ec247..a221aaef 100644 --- a/annotationprocessor/src/main/java/io/toolisticon/annotationprocessortoolkit/tools/fluentfilter/FluentElementFilter.java +++ b/annotationprocessor/src/main/java/io/toolisticon/annotationprocessortoolkit/tools/fluentfilter/FluentElementFilter.java @@ -160,7 +160,7 @@ public FluentElementFilter filterByAllOf(CHARACTERISTIC... criteria) { * @param coreMatcher the implicit core matcher to use * @return the FluentElementFilter instance */ - public FluentElementFilter applyFilter(IsCoreMatcher coreMatcher) { + public FluentElementFilter is(IsCoreMatcher coreMatcher) { elements = coreMatcher.getFilter().filter(elements); return new FluentElementFilter((List) elements); @@ -173,7 +173,7 @@ public FluentElementFilter appl * @param coreMatcher the implicit core matcher to use * @return the FluentElementFilter instance */ - public FluentElementFilter applyInvertedFilter(IsCoreMatcher coreMatcher) { + public FluentElementFilter isNot(IsCoreMatcher coreMatcher) { elements = coreMatcher.getFilter().filter(elements, true); return FluentElementFilter.this; @@ -187,7 +187,7 @@ public FluentElementFilter applyInvert * @param coreMatcher the implicit core matcher to use * @return the FluentElementFilter instance */ - public FluentElementFilter applyFilter(IsElementBasedCoreMatcher coreMatcher) { + public FluentElementFilter is(IsElementBasedCoreMatcher coreMatcher) { elements = (List) coreMatcher.getFilter().filter((List) elements); return new FluentElementFilter((List) elements); @@ -200,7 +200,7 @@ public FluentElementFilter appl * @param coreMatcher the implicit core matcher to use * @return the FluentElementFilter instance */ - public FluentElementFilter applyInvertedFilter(IsElementBasedCoreMatcher coreMatcher) { + public FluentElementFilter isNot(IsElementBasedCoreMatcher coreMatcher) { elements = (List) coreMatcher.getFilter().filter((List) elements, true); return FluentElementFilter.this; diff --git a/annotationprocessor/src/main/java/io/toolisticon/annotationprocessortoolkit/tools/fluentvalidator/FluentElementValidator.java b/annotationprocessor/src/main/java/io/toolisticon/annotationprocessortoolkit/tools/fluentvalidator/FluentElementValidator.java index e67affe0..cda6a126 100644 --- a/annotationprocessor/src/main/java/io/toolisticon/annotationprocessortoolkit/tools/fluentvalidator/FluentElementValidator.java +++ b/annotationprocessor/src/main/java/io/toolisticon/annotationprocessortoolkit/tools/fluentvalidator/FluentElementValidator.java @@ -1,6 +1,7 @@ package io.toolisticon.annotationprocessortoolkit.tools.fluentvalidator; import io.toolisticon.annotationprocessortoolkit.tools.MessagerUtils; +import io.toolisticon.annotationprocessortoolkit.tools.corematcher.CoreMatchers; import io.toolisticon.annotationprocessortoolkit.tools.corematcher.ExclusiveCriteriaCoreMatcher; import io.toolisticon.annotationprocessortoolkit.tools.corematcher.ExclusiveCriteriaElementBasedCoreMatcher; import io.toolisticon.annotationprocessortoolkit.tools.corematcher.ImplicitCoreMatcher; @@ -17,6 +18,7 @@ import io.toolisticon.annotationprocessortoolkit.tools.validator.InclusiveCriteriaElementValidator; import javax.lang.model.element.Element; +import javax.lang.model.element.Modifier; import javax.tools.Diagnostic; /** @@ -24,6 +26,252 @@ */ public class FluentElementValidator { + /** + * Apply validator interface. + */ + public class PrepareApplyValidator { + + /** + * Set warning scope for next validation. + * + * @return the fluent validator instance + */ + public PrepareApplyValidator warning() { + return (PrepareApplyValidator) FluentElementValidator.this.warning(); + } + + /** + * Set note scope for next validation. + * + * @return the fluent validator instance + */ + public PrepareApplyValidator note() { + return (PrepareApplyValidator) FluentElementValidator.this.note(); + } + + /** + * Set warning scope for next validation. + * + * @param customMessage the custom message to use. + * @return the fluent validator instance + */ + public PrepareApplyValidator setCustomMessage(String customMessage) { + return (PrepareApplyValidator) FluentElementValidator.this.setCustomMessage(customMessage); + } + + + /** + * Applies is validator. + * Changes generic type of fluent validator. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public FluentElementValidator is(IsCoreMatcher coreMatcher) { + + return FluentElementValidator.this.is(coreMatcher); + + } + + /** + * Applies inverted is filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public FluentElementValidator isNot(IsCoreMatcher coreMatcher) { + + return FluentElementValidator.this.isNot(coreMatcher); + + } + + /** + * Applies is element based filter. + * Changes generic type of fluent filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public FluentElementValidator is(IsElementBasedCoreMatcher coreMatcher) { + + return FluentElementValidator.this.is(coreMatcher); + + + } + + /** + * Applies inverted implicit element based filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public FluentElementValidator isNot(IsElementBasedCoreMatcher coreMatcher) { + + return FluentElementValidator.this.isNot(coreMatcher); + + } + + // ----------------------------------------------- + // -- IMPLICIT FILTERS + // ----------------------------------------------- + + /** + * Applies implicit filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public FluentElementValidator applyValidator(ImplicitCoreMatcher coreMatcher) { + + return FluentElementValidator.this.applyValidator(coreMatcher); + + } + + /** + * Applies inverted implicit filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public FluentElementValidator applyInvertedValidator(ImplicitCoreMatcher coreMatcher) { + + return FluentElementValidator.this.applyInvertedValidator(coreMatcher); + + } + + /** + * Applies implicit element based filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public FluentElementValidator applyValidator(ImplicitElementBasedCoreMatcher coreMatcher) { + + return FluentElementValidator.this.applyValidator(coreMatcher); + + } + + /** + * Applies inverted implicit element based filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public FluentElementValidator applyInvertedVaidator(ImplicitElementBasedCoreMatcher coreMatcher) { + + return FluentElementValidator.this.applyInvertedValidator(coreMatcher); + + } + + // ----------------------------------------------- + // -- INCLUSIVE CRITERIA FILTERS + // ----------------------------------------------- + + /** + * Applies inclusive criteria filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public InclusiveCharacteristicFluentValidator applyValidator(InclusiveCriteriaCoreMatcher coreMatcher) { + + return FluentElementValidator.this.applyValidator(coreMatcher); + + } + + /** + * Applies inverted inclusive criteria filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public InclusiveCharacteristicFluentValidator applyInvertedValidator(InclusiveCriteriaCoreMatcher coreMatcher) { + + return FluentElementValidator.this.applyInvertedValidator(coreMatcher); + + } + + /** + * Applies inclusive criteria element based filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public InclusiveCharacteristicFluentValidator applyValidator(InclusiveCharacteristicElementBasedCoreMatcher coreMatcher) { + + return FluentElementValidator.this.applyValidator(coreMatcher); + + + } + + /** + * Applies inverted inclusive element based criteria filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public InclusiveCharacteristicFluentValidator applyInvertedValidator(InclusiveCharacteristicElementBasedCoreMatcher coreMatcher) { + + return FluentElementValidator.this.applyInvertedValidator(coreMatcher); + + } + + // ----------------------------------------------- + // -- EXPLICIT FILTERS + // ----------------------------------------------- + + /** + * Applies exclusive criteria filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public ExclusiveCharacteristicFluentValidator applyValidator(ExclusiveCriteriaCoreMatcher coreMatcher) { + + return FluentElementValidator.this.applyValidator(coreMatcher); + + } + + /** + * Applies inverted exclusive criteria filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public ExclusiveCharacteristicFluentValidator applyInvertedValidator(ExclusiveCriteriaCoreMatcher coreMatcher) { + + return FluentElementValidator.this.applyInvertedValidator(coreMatcher); + + } + + /** + * Applies exclusive criteria element based filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public ExclusiveCharacteristicFluentValidator applyValidator(ExclusiveCriteriaElementBasedCoreMatcher coreMatcher) { + + return FluentElementValidator.this.applyValidator(coreMatcher); + + + } + + + /** + * Applies inverted exclusive element based criteria filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public ExclusiveCharacteristicFluentValidator applyInvertedValidator(ExclusiveCriteriaElementBasedCoreMatcher coreMatcher) { + + return FluentElementValidator.this.applyInvertedValidator(coreMatcher); + + } + + } + /** * The element under validation. @@ -36,50 +284,54 @@ public class FluentElementValidator { */ private final FluentValidatorState fluentValidatorState; - /** - * The base class for all validators. - * - * @param - * @param - */ - public abstract class AbstractFluentValidatorBase> { - - private Diagnostic.Kind messageScope = Diagnostic.Kind.ERROR; - private String message = null; - private boolean invert = false; + private NextValidationContext nextValidationContext = new NextValidationContext(); + private class NextValidationContext { - public VALIDATOR not() { + private String customMessage; + private Diagnostic.Kind messageScope = Diagnostic.Kind.ERROR; - invert = true; - return self(); + private void reset() { + customMessage = null; + messageScope = Diagnostic.Kind.ERROR; + } + public String getCustomMessage() { + return customMessage; } - public VALIDATOR warn() { + public void setCustomMessage(String customMessage) { + this.customMessage = customMessage; + } - messageScope = Diagnostic.Kind.MANDATORY_WARNING; - return self(); + public Diagnostic.Kind getMessageScope() { + return messageScope; + } + public void setMessageScope(Diagnostic.Kind messageScope) { + this.messageScope = messageScope; } + } - public VALIDATOR message(String messsage) { + /** + * The base class for all validators. + * + * @param + * @param + */ + public abstract class AbstractFluentValidatorBase> { - this.message = messsage; - return self(); + private boolean inverted = false; + + public AbstractFluentValidatorBase(final boolean inverted) { + this.inverted = inverted; } protected abstract VALIDATOR self(); protected boolean isInverted() { - return invert; - } - - private String getMessage() { - - return message; - + return inverted; } @@ -90,15 +342,18 @@ private String getMessage() { */ protected void setValidationResult(boolean validationResult, String defaultMessage, Object... messsageParameter) { - if ((!validationResult && !invert) || (validationResult && invert)) { + if ((!validationResult && !inverted) || (validationResult && inverted)) { fluentValidatorState.setAsFailedValidation(); - if (message != null) { - MessagerUtils.getMessagerUtils().printMessage(element, messageScope, message); + if (nextValidationContext.getCustomMessage() != null) { + MessagerUtils.getMessagerUtils().printMessage(element, nextValidationContext.getMessageScope(), nextValidationContext.getCustomMessage()); } else { - MessagerUtils.getMessagerUtils().printMessage(element, messageScope, defaultMessage, messsageParameter); + MessagerUtils.getMessagerUtils().printMessage(element, nextValidationContext.getMessageScope(), defaultMessage, messsageParameter); } + // rest validation context for next validation + nextValidationContext.reset(); + } } @@ -116,7 +371,8 @@ public class ImplicitFluentValidator extends private final ImplicitValidator> validator; - private ImplicitFluentValidator(ImplicitValidator> validator) { + private ImplicitFluentValidator(ImplicitValidator> validator, boolean inverted) { + super(inverted); this.validator = validator; } @@ -144,7 +400,8 @@ public class IsFluentValidator> validator; - private IsFluentValidator(ImplicitValidator> validator) { + private IsFluentValidator(ImplicitValidator> validator, boolean inverted) { + super(inverted); this.validator = validator; } @@ -169,6 +426,40 @@ protected IsFluentValidator self() { } } + /** + * Validator step for inverted is validators. + * + * @param + */ + public class InvertedIsFluentValidator extends AbstractFluentValidatorBase> { + + private final ImplicitValidator> validator; + + private InvertedIsFluentValidator(ImplicitValidator> validator, boolean inverted) { + super(inverted); + this.validator = validator; + } + + public FluentElementValidator apply() { + + + boolean validationResult = false; + + // just validate if element != null + if (element != null) { + validationResult = validator.validate((VALIDATOR_ELEMENT) element); + setValidationResult(validationResult, validator.getMessage()); + } + + return FluentElementValidator.this; + + } + + @Override + protected InvertedIsFluentValidator self() { + return this; + } + } /** * Validator step for exlusive characteristics validators. @@ -180,7 +471,8 @@ public class ExclusiveCharacteristicFluentValidator> validator; - private ExclusiveCharacteristicFluentValidator(ExclusiveCriteriaElementValidator> validator) { + private ExclusiveCharacteristicFluentValidator(ExclusiveCriteriaElementValidator> validator, boolean inverted) { + super(inverted); this.validator = validator; } @@ -216,7 +508,8 @@ public class InclusiveCharacteristicFluentValidator> validator; - private InclusiveCharacteristicFluentValidator(InclusiveCriteriaElementValidator> validator) { + private InclusiveCharacteristicFluentValidator(InclusiveCriteriaElementValidator> validator, boolean inverted) { + super(inverted); this.validator = validator; } @@ -269,43 +562,238 @@ private FluentElementValidator(ELEMENT element, FluentValidatorState fluentValid this.fluentValidatorState = fluentValidatorState; } + // ----------------------------------------------- + // -- IS VALIDATOR + // ----------------------------------------------- + + /** + * Applies is validator. + * Changes generic type of fluent validator. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public FluentElementValidator is(IsCoreMatcher coreMatcher) { + + return new IsFluentValidator(coreMatcher.getValidator(), false).apply(); - // apply implicit validators - public ImplicitFluentValidator applyValidator(ImplicitCoreMatcher coreMatcher) { - return new ImplicitFluentValidator(coreMatcher.getValidator()); } - public ImplicitFluentValidator applyValidator(ImplicitElementBasedCoreMatcher coreMatcher) { - return new ImplicitFluentValidator(coreMatcher.getValidator()); + /** + * Applies inverted is filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public FluentElementValidator isNot(IsCoreMatcher coreMatcher) { + + return new InvertedIsFluentValidator(coreMatcher.getValidator(), true).apply(); + } - // apply inclusive characteristics validators - public InclusiveCharacteristicFluentValidator applyValidator(InclusiveCriteriaCoreMatcher coreMatcher) { - return new InclusiveCharacteristicFluentValidator(coreMatcher.getValidator()); + /** + * Applies is element based filter. + * Changes generic type of fluent filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public FluentElementValidator is(IsElementBasedCoreMatcher coreMatcher) { + + return new IsFluentValidator(coreMatcher.getValidator(), false).apply(); + + } - public InclusiveCharacteristicFluentValidator applyValidator(InclusiveCharacteristicElementBasedCoreMatcher coreMatcher) { - return new InclusiveCharacteristicFluentValidator(coreMatcher.getValidator()); + /** + * Applies inverted implicit element based filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public FluentElementValidator isNot(IsElementBasedCoreMatcher coreMatcher) { + + return new InvertedIsFluentValidator(coreMatcher.getValidator(), true).apply(); + } - // apply exclusive characteristics validators - public ExclusiveCharacteristicFluentValidator applyValidator(ExclusiveCriteriaCoreMatcher coreMatcher) { - return new ExclusiveCharacteristicFluentValidator(coreMatcher.getValidator()); + // ----------------------------------------------- + // -- IMPLICIT FILTERS + // ----------------------------------------------- + + /** + * Applies implicit filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public FluentElementValidator applyValidator(ImplicitCoreMatcher coreMatcher) { + + return new ImplicitFluentValidator(coreMatcher.getValidator(), false).apply(); + } - public ExclusiveCharacteristicFluentValidator applyValidator(ExclusiveCriteriaElementBasedCoreMatcher coreMatcher) { - return new ExclusiveCharacteristicFluentValidator(coreMatcher.getValidator()); + /** + * Applies inverted implicit filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public FluentElementValidator applyInvertedValidator(ImplicitCoreMatcher coreMatcher) { + + return new ImplicitFluentValidator(coreMatcher.getValidator(), true).apply(); + } - // apply is validators - public FluentElementValidator is(IsCoreMatcher coreMatcher) { - return new IsFluentValidator(coreMatcher.getValidator()).apply(); + /** + * Applies implicit element based filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public FluentElementValidator applyValidator(ImplicitElementBasedCoreMatcher coreMatcher) { + + return new ImplicitFluentValidator(coreMatcher.getValidator(), true).apply(); + } - public FluentElementValidator is(IsElementBasedCoreMatcher coreMatcher) { - return new IsFluentValidator(coreMatcher.getValidator()).apply(); + /** + * Applies inverted implicit element based filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public FluentElementValidator applyInvertedValidator(ImplicitElementBasedCoreMatcher coreMatcher) { + + return new ImplicitFluentValidator(coreMatcher.getValidator(), true).apply(); + } + // ----------------------------------------------- + // -- INCLUSIVE CRITERIA FILTERS + // ----------------------------------------------- + + /** + * Applies inclusive criteria filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public InclusiveCharacteristicFluentValidator applyValidator(InclusiveCriteriaCoreMatcher coreMatcher) { + + return new InclusiveCharacteristicFluentValidator(coreMatcher.getValidator(), false); + + } + + /** + * Applies inverted inclusive criteria filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public InclusiveCharacteristicFluentValidator applyInvertedValidator(InclusiveCriteriaCoreMatcher coreMatcher) { + + return new InclusiveCharacteristicFluentValidator(coreMatcher.getValidator(), true); + + } + + /** + * Applies inclusive criteria element based filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public InclusiveCharacteristicFluentValidator applyValidator(InclusiveCharacteristicElementBasedCoreMatcher coreMatcher) { + + return new InclusiveCharacteristicFluentValidator(coreMatcher.getValidator(), false); + + + } + + /** + * Applies inverted inclusive element based criteria filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public InclusiveCharacteristicFluentValidator applyInvertedValidator(InclusiveCharacteristicElementBasedCoreMatcher coreMatcher) { + + return new InclusiveCharacteristicFluentValidator(coreMatcher.getValidator(), true); + + } + + // ----------------------------------------------- + // -- EXPLICIT FILTERS + // ----------------------------------------------- + + /** + * Applies exclusive criteria filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public ExclusiveCharacteristicFluentValidator applyValidator(ExclusiveCriteriaCoreMatcher coreMatcher) { + + return new ExclusiveCharacteristicFluentValidator(coreMatcher.getValidator(), false); + + } + + /** + * Applies inverted exclusive criteria filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public ExclusiveCharacteristicFluentValidator applyInvertedValidator(ExclusiveCriteriaCoreMatcher coreMatcher) { + + return new ExclusiveCharacteristicFluentValidator(coreMatcher.getValidator(), true); + + } + + /** + * Applies exclusive criteria element based filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public ExclusiveCharacteristicFluentValidator applyValidator(ExclusiveCriteriaElementBasedCoreMatcher coreMatcher) { + + return new ExclusiveCharacteristicFluentValidator(coreMatcher.getValidator(), false); + } + + /** + * Applies inverted exclusive element based criteria filter. + * + * @param coreMatcher the implicit core matcher to use + * @return the FluentElementValidator instance + */ + public ExclusiveCharacteristicFluentValidator applyInvertedValidator(ExclusiveCriteriaElementBasedCoreMatcher coreMatcher) { + + return new ExclusiveCharacteristicFluentValidator(coreMatcher.getValidator(), true); + + } + + // ------------------------------------------------------------- + // ------------------------------------------------------------- + + public PrepareApplyValidator warning() { + this.nextValidationContext.setMessageScope(Diagnostic.Kind.WARNING); + return new PrepareApplyValidator(); + } + + public PrepareApplyValidator note() { + this.nextValidationContext.setMessageScope(Diagnostic.Kind.NOTE); + return new PrepareApplyValidator(); + } + + public PrepareApplyValidator setCustomMessage(String customMessage) { + this.nextValidationContext.setCustomMessage(customMessage); + return new PrepareApplyValidator(); + } + + // ------------------------------------------------------------- + // ------------------------------------------------------------- + /** * Just return the validation result without issuing any messages. @@ -336,4 +824,13 @@ public static FluentElementValidator createFluentElementV } + public static void main(String[] args) { + createFluentElementValidator(null) + .isNot(CoreMatchers.IS_EXECUTABLE_ELEMENT) + .is(CoreMatchers.IS_TYPE_ELEMENT) + .warning().setCustomMessage("").applyValidator(CoreMatchers.BY_MODIFIER).hasOneOf(Modifier.PUBLIC) + .validateAndIssueMessages(); + } + + } diff --git a/example/example-annotationprocessor/src/main/java/io/toolisticon/example/annotationprocessortoolkit/annotationprocessor/MethodWithOneStringParameterAndVoidReturnTypeAnnotationProcessor.java b/example/example-annotationprocessor/src/main/java/io/toolisticon/example/annotationprocessortoolkit/annotationprocessor/MethodWithOneStringParameterAndVoidReturnTypeAnnotationProcessor.java index 2beb4414..abdf7148 100644 --- a/example/example-annotationprocessor/src/main/java/io/toolisticon/example/annotationprocessortoolkit/annotationprocessor/MethodWithOneStringParameterAndVoidReturnTypeAnnotationProcessor.java +++ b/example/example-annotationprocessor/src/main/java/io/toolisticon/example/annotationprocessortoolkit/annotationprocessor/MethodWithOneStringParameterAndVoidReturnTypeAnnotationProcessor.java @@ -43,7 +43,7 @@ public boolean processAnnotations(Set annotations, RoundE // validator already will print output so additional actions are not necessary FluentElementValidator.createFluentElementValidator(ElementUtils.CastElement.castMethod(element)) - .applyValidator(CoreMatchers.HAS_VOID_RETURN_TYPE).apply() + .applyValidator(CoreMatchers.HAS_VOID_RETURN_TYPE) .applyValidator(CoreMatchers.BY_PARAMETER_TYPE).hasOneOf(wrapToArray(String.class)) .validateAndIssueMessages();