public interface FlowValidator {
/**
- * Names of items to be validated
+ * Should this validator run for given bb
* @return
*/
- public Set<String> forItems();
+ public boolean shouldRunFor(String bbName);
/**
* Determines whether or not the workflow should be executed
protected List<FlowValidator> filterValidators(List<? extends FlowValidator> validators, String bbName) {
return validators.stream()
.filter(item -> {
- return item.forItems().contains(bbName);
+ return item.shouldRunFor(bbName);
})
.sorted(Comparator.comparing(item -> {
Priority p = Optional.ofNullable(item.getClass().getAnnotation(Priority.class)).orElse(new Priority() {
public class MyPreValidatorFour implements PreBuildingBlockValidator {
@Override
- public Set<String> forItems() {
- return Collections.singleton("test2");
+ public boolean shouldRunFor(String bbName) {
+ return Collections.singleton("test2").contains(bbName);
}
@Override
public class MyPreValidatorOne implements PreBuildingBlockValidator {
@Override
- public Set<String> forItems() {
+ public boolean shouldRunFor(String bbName) {
- return Collections.singleton("test");
+ return Collections.singleton("test").contains(bbName);
}
@Override
public class MyPreValidatorThree implements PreBuildingBlockValidator {
@Override
- public Set<String> forItems() {
- return Collections.singleton("test2");
+ public boolean shouldRunFor(String bbName) {
+ return Collections.singleton("test2").contains(bbName);
}
@Override
public class MyPreValidatorTwo implements PreBuildingBlockValidator {
@Override
- public Set<String> forItems() {
- return Collections.singleton("test");
+ public boolean shouldRunFor(String bbName) {
+ return Collections.singleton("test").contains(bbName);
}
@Override
public class WorkflowPreValidatorOne implements PreWorkflowValidator {
@Override
- public Set<String> forItems() {
+ public boolean shouldRunFor(String bbName) {
- return Collections.singleton("test");
+ return Collections.singleton("test").contains(bbName);
}
@Override
public class WorkflowPreValidatorTwo implements PreWorkflowValidator {
@Override
- public Set<String> forItems() {
- return Collections.singleton("test");
+ public boolean shouldRunFor(String bbName) {
+ return Collections.singleton("test").contains(bbName);
}
@Override