Package epam.legalage

Class LegalAgePredicate

java.lang.Object
epam.legalage.LegalAgePredicate
All Implemented Interfaces:
Predicate<LocalDate>

public final class LegalAgePredicate extends Object implements Predicate<LocalDate>
A predicate that checks if a user is over 18 years old based on their date of birth.
  • Constructor Details

    • LegalAgePredicate

      public LegalAgePredicate()
      Creates a LegalAgePredicate with the system default clock.
    • LegalAgePredicate

      public LegalAgePredicate(Clock clock)
      Creates a LegalAgePredicate with the specified clock.
      Parameters:
      clock - the clock to use for calculating the current date
  • Method Details

    • test

      public boolean test(LocalDate dateOfBirth)
      Tests if the user with the given date of birth is over 18 years old.
      Specified by:
      test in interface Predicate<LocalDate>
      Parameters:
      dateOfBirth - the user's date of birth
      Returns:
      true if the user is over 18 years old, false otherwise