01
Assignment Overview
Build a mini Validation Framework that uses annotations to validate objects and lambdas for custom validation rules. This project demonstrates practical applications of advanced Java features.
Skills Applied: Lambda Expressions (8.1), Annotations (8.2), and Reflection API (8.3) from Module 8.
Lambdas
Functional interfaces, method references, streams
Annotations
Custom annotations, retention, targets
Reflection
Class introspection, dynamic invocation
02
Requirements
Part 1: Custom Validation Annotations (40 points)
- Create
@NotNull,@NotEmpty,@Range,@Email,@Patternannotations - Use
@Retention(RUNTIME)for runtime processing - Use
@Target(FIELD)to restrict to fields - Include attributes like
message,min,max
Part 2: Validation Engine with Reflection (50 points)
- Create a
Validatorclass that processes annotated objects - Use reflection to read field annotations
- Implement validation logic for each annotation type
- Return a list of
ValidationErrorobjects
Part 3: Lambda-based Custom Validators (35 points)
- Create a
ValidationRule<T>functional interface - Allow users to register custom validators using lambdas
- Support method references for common validations
- Chain multiple validators using
andThen()
Part 4: Demonstration (25 points)
- Create sample entity classes with validation annotations
- Demonstrate all annotation types working correctly
- Show custom lambda validators in action
- Display clear error messages
03
Submission Guidelines
Folder Structure: Submit all files in a folder named
assignment8_yourname
Required Files:
annotations/- All custom annotation definitionsValidator.java- Main validation engineValidationRule.java- Functional interfaceValidationError.java- Error modelvalidators/- Built-in validatorsentities/- Sample entity classesMain.java- DemonstrationREADME.txt
Ready to submit? Test with various valid and invalid inputs!
Submit Now
04
Grading Rubric
| Criteria | Points | Description |
|---|---|---|
| Custom Annotations | 40 | Proper annotation design with attributes |
| Validation Engine | 50 | Correct reflection usage for processing |
| Lambda Validators | 35 | Functional interface and lambda usage |
| Demonstration | 25 | Comprehensive testing and examples |
| Total | 150 |