Assignment 8-A

Advanced Java Techniques

Apply advanced Java features including lambdas, annotations, and reflection. Build a mini framework that showcases functional programming and metaprogramming capabilities.

5-6 hours
Advanced
150 Points
Submit Assignment
What You'll Practice
  • Write lambda expressions
  • Create custom annotations
  • Use reflection API
  • Apply functional programming
  • Build annotation processors
Contents
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, @Pattern annotations
  • 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 Validator class that processes annotated objects
  • Use reflection to read field annotations
  • Implement validation logic for each annotation type
  • Return a list of ValidationError objects

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:
  1. annotations/ - All custom annotation definitions
  2. Validator.java - Main validation engine
  3. ValidationRule.java - Functional interface
  4. ValidationError.java - Error model
  5. validators/ - Built-in validators
  6. entities/ - Sample entity classes
  7. Main.java - Demonstration
  8. README.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