package Ġn tn u . id att 2 1 0 5 . reservation . validation Ċ Ċ import Ġn tn u . id att 2 1 0 5 . core . util . Reservation Constants Ċ import Ġn tn u . id att 2 1 0 5 . reservation . dto . Reservation Create Dto Ċ import Ġjava . time . Duration Ċ import Ġjavax . validation . Constraint Validator Ċ import Ġjavax . validation . Constraint Validator Context Ċ Ċ class ĠReser vation Maximum Duration Validator Ġ: ĊĠĠĠ ĠConstraint Validator < Reservation Maximum Duration ?, ĠReser vation Create Dto > Ġ{ ĊĊĠĠĠ Ġoverride Ġfun Ġinitialize ( constraint Annotation : ĠReser vation Maximum Duration ?) Ġ{ ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠisValid ( reservation : ĠReser vation Create Dto , Ġconstraint Validator Context : ĠConstraint Validator Context ): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġis Max 1 4 Hours Ġ= ĠDuration . between ( reservation . from Time , Ġreservation . to Time ). to Hours () Ġ<= ĠReser vation Constants . MAX _ DURATION ĊĠĠĠĠĠĠĠ Ġreturn Ġis Max 1 4 Hours ĊĠĠĠ Ġ} Ċ } Ċ