Guest User

Untitled

a guest
Nov 16th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. @Component
  2. @AllArgsConstructor(onConstructor = @__(@Autowired))
  3. public class ValidatorFactory {
  4. private List<BaseValidator> validators;
  5.  
  6. /**
  7. * Filter out all unnecessary validation classes by checking event types
  8. * and returns only needed ones.
  9. *
  10. * @param isExclusive: the boolean value indicate whether the event is the exclusive one or not
  11. * @return All necessary validation methods
  12. */
  13. List<BaseValidator> get(boolean isExclusive) {
  14. EnumSet<ValidateType> eventTypes = ValidateType.getEventTypes(isExclusive);
  15. return validators.stream().filter(v -> eventTypes.contains(v.getValidateType())).collect(Collectors.toList());
  16. }
  17. }
Add Comment
Please, Sign In to add comment