write own impl of Predicate in CandidateValidator and implement metho…#1397
write own impl of Predicate in CandidateValidator and implement metho…#1397polina-kirf wants to merge 1 commit into
Conversation
…ds in StreamPractice
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your solution is approved because it correctly implements all required functionality using the Stream API, including the minimum even number search, odd numbers average with proper exception behavior, and all the people/candidates filtering rules as described. The CandidateValidator correctly enforces age (35+), nationality, voting permission, and total years in Ukraine based on the parsed periodsInUkr string, and validateCandidates reuses this predicate and returns sorted names.
There are no critical or blocking issues to fix for this task. As a minor polish, the Javadoc for validateCandidates currently says candidates must be "older than 35 years", while your code checks age >= 35; consider rewording this to something like "at least 35 years old" so the documentation matches the logic. Another optional improvement: in CandidateValidator, the loop that parses and sums periodsInUkr is clear and correct, but you could experiment with converting this to a stream-based summation for stylistic consistency with the rest of your stream-heavy code.
Overall, you met the task requirements well, used streams appropriately (no loops in StreamPractice), and followed the checklist items such as proper exception messages, enum comparison with ==, and avoiding magic numbers via constants. Nice work—these are solid, idiomatic stream solutions and a good use of Predicate<Candidate> for reusable validation.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
…ds in StreamPractice