Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Component
- @AllArgsConstructor(onConstructor = @__(@Autowired))
- public class ValidatorFactory {
- private List<BaseValidator> validators;
- /**
- * Filter out all unnecessary validation classes by checking event types
- * and returns only needed ones.
- *
- * @param isExclusive: the boolean value indicate whether the event is the exclusive one or not
- * @return All necessary validation methods
- */
- List<BaseValidator> get(boolean isExclusive) {
- EnumSet<ValidateType> eventTypes = ValidateType.getEventTypes(isExclusive);
- return validators.stream().filter(v -> eventTypes.contains(v.getValidateType())).collect(Collectors.toList());
- }
- }
Add Comment
Please, Sign In to add comment