-
Annotation-based Field Validator
- Define a custom annotation
@NotNull
to mark fields that cannot be null. - Create a validator method that:
- Scans for fields annotated with
@NotNull
and ensures they are non-null. - Prints a message if any
@NotNull
field is null.
- Scans for fields annotated with
- Test on a class containing both nullable and non-nullable fields. AnnotationbasedFieldValidator
- Define a custom annotation
-
Multi Annotation-based Field Validator
- Define custom annotations
@NotNull
and@MinLength
. - Write a validator method that:
- Supports multiple annotations on fields.
- Ensures fields with
@NotNull
are non-null and those with@MinLength
meet the length criteria.
- Test with a class containing fields with various constraints. MultiAnnotationOnFieldValidator
- Define custom annotations
-
Simple Dependency Injection Framework
- Define an
@Inject
annotation for dependency injection. - Create a utility that:
- Instantiates objects for fields annotated with
@Inject
. - Injects dependencies automatically, e.g., injecting an
Engine
into aCar
. SimpleDependencyInjection
- Instantiates objects for fields annotated with
- Define an
-
Custom Serialization Utility with Annotations
- Define
@Serializable
and@IgnoreField
annotations for custom serialization. - Write a utility that:
- Serializes objects to JSON format, including only
@Serializable
fields. - Ignores fields marked with
@IgnoreField
.
- Serializes objects to JSON format, including only
- Test with sample classes containing dependencies on other serializable classes. CustomSerializationUtility
- Define
-
Annotation-based Test Runner -> Similar to Junit Library in Spring
- Create a
@Test
annotation to mark test methods. - Write a test runner that:
- Finds and runs methods annotated with
@Test
. - Reports the result (pass/fail) and logs exceptions.
- Finds and runs methods annotated with
- Functions like a mini-JUnit framework. AnnotationbasedTestRunner
- Create a
-
Custom Access Control Using Annotations -> Kind of Proxy Design Implementation
- Define an annotation
@Role
with parameters like "ADMIN", "USER", or "GUEST". - Annotate methods with different role requirements.
- Write an access control method to:
- Check a user’s role against the required role for a method.
- Grant or deny access accordingly, even in a multi-threaded environment. CustomAccessControl
- Define an annotation
-
Factory Pattern with Annotations -> Factory Design Pattern and simmilar to AutoWired Constructor Injection in Spring
- Define a
@Factory
annotation to indicate the constructor to use for object creation. - Create a factory utility that:
- Finds the annotated constructor and instantiates the object.
- Use for dynamic instantiation based on annotations. FactoryPatternwithAnnotations
- Define a
-
Automatic Scope Manager -> Similar to Scope in SpringBoot
- Define an annotation
@Scope
for managing object lifecycles as Singleton or Prototype. - Write a utility that:
- Ensures one instance per class for Singleton.
- Creates new instances each time for Prototype. AutomaticScopeManager
- Define an annotation
-
Enum-based Configuration Loader
- Define a
@Config
annotation with a key parameter. - Create an
AppConfig
enum for configuration settings, annotated with@Config
. - Write a loader that reads configurations from a properties file and populates the enum constants. EnumbasedConfigurationLoader
- Define a
-
Annotation-Based SQL Query Builder -> Similar to ORM framework like Hibernate/JPA Mapping in SpringBoot
- This project implements an Annotation-Based SQL Query Builder that uses annotations such as
@Table
,@Column
, and@Id
for a simple ORM-like setup. The query builder generates SQL CRUD (Create, Read, Update, Delete) statements by reading annotations from a given entity class.- SQL Query Generation: The builder reads annotations like
@Table
,@Column
,@Id
,@OneToOne
,@OneToMany
, and@ManyToMany
to generate SQL CRUD statements dynamically. - Supports Relationships: It handles various relationships between entities, including:
@OneToOne
@OneToMany
@ManyToMany
@Column
(Standard column mapping)
- Inner Classes: The builder can process inner classes that contain these annotations as well.
- Spring Data JPA Demonstration: This project demonstrates how annotations can simplify the mapping of database tables to Java classes, similar to how Spring Data JPA works. AnnotationbasedSQLQueryBuilder
- SQL Query Generation: The builder reads annotations like
- CreateQueryBuilder: Not yet implemented.
- DeleteQueryBuilder: Not yet implemented.
- UpdateQueryBuilder: Not yet implemented.
- SelectQueryBuilder: Completed and functional. Generates dynamic
SELECT
SQL queries based on entity annotations. - selectQuerySimulator: To be implemented to simulate and showcase the working of the
SELECT
query builder.
- This project implements an Annotation-Based SQL Query Builder that uses annotations such as
-
Thread-safe Singleton Implementation
-
Implement a thread-safe singleton using
BillPlugh
orDouble-checked Locking
. -
The inclusion of tests for serialization and deserialization to ensure the Singleton behaves as expected when serialized and deserialized
-
-
Producer-Consumer Problem
- Implement a producer-consumer model where producers add items to a shared bounded buffer and consumers remove items.
- Implement this with multiple producer and consumer threads and use wait() and notifyAll() for inter-thread communication.
-
Thread Pool Implementation
- Implement a custom thread pool manager simmilar to
ThreadPoolExecutor
.
- Implement a custom thread pool manager simmilar to
-
MultithreadedCounter
- Write a program that uses multiple threads to increment a shared counter variable. Use synchronization techniques to ensure the counter’s integrity.
- Extend the solution to make the counter thread-safe without using synchronized.
-
CyclicOrderedPrintingWithMultipleThreads
-
Multiple Threads are involved, each with its own start point.
-
Incremental Progress indicates that the value printed by each thread increases according to a user-defined increment.
-
Using IPC specifies that inter-thread communication mechanisms (like wait() and notify()) are employed for synchronization.
-
-
CustomBlockingQueueImpl
-
Custom Blocking Queue with Condition Variables
-
Create a BlockingQueue implementation using Condition objects from ReentrantLock, ReadWriteLock, StampLock.
-
use Strategy Design pattern to implement run time algorithm fo locking and synchronization
-
Demonstrate producers adding items and consumers taking items.
-
-
DeadlockSimulationandResolution
-
Write a program that intentionally creates a deadlock situation between two threads.
-
After observing the deadlock, modify the code to resolve it using one or more techniques (like ordering resources, timeout, or tryLock()).
-
-
Synchronous Task Pipeline Using CompletetableFuture
-
uses CompletableFuture for chaining the tasks across stages, where the fetch, process, and save stages each run in separate threads
-
Each stage start once that stage is fully completed i.e process start once fetch is over and save Stage start onec process is over. after processs Stage it moves to final stage
-
Fetch Stage: Reads data from a file asynchronously and passes it to the process stage.
-
Process Stage: Processes the fetched data (e.g., transforms it to uppercase) and sends it to the save stage.
-
Save Stage: Writes the processed data to an output file.
-
-
Asynchronous Task Pipeline Similar to Producer Consumer ..
- uses CompletableFuture for chaining the tasks across stages, where the fetch, process, and save stages each run in separate threads
- Fetch Data: Asynchronously fetches data from the file and puts it into the BlockingQueue. It doesn’t wait for the fetch to complete before moving to the next stage.
- Process Data: Asynchronously processes data from the BlockingQueue and immediately passes it to the BlockingQueue of the save stage.
- Save Data: Asynchronously consumes processed data from the BlockingQueue and saves it to the file.
-
MultithreadedFileReader
- Write a program to read a large file in parallel using multiple threads.
- Divide the file into parts, each read by a separate thread, and then combine the results in order.
- Ensure thread safety if threads need to update a shared data structure.
-
ParallelFileSearch
-
Write a program to search for a specific keyword within multiple files in parallel.
-
Each thread should search one file, and the program should return a list of files where the keyword was found.
-
Use Future and Callable to handle tasks and collect results.
-
-
PriorityTaskScheduler
-
ThreadSafeCachewithExpiryMechanism
-
Thread-safe Cache with Expiry Mechanism
-
Design a thread-safe cache with the following properties:
-
Each item in the cache has a time-to-live (TTL) value.
-
Expired items should be removed automatically without blocking the main operation.
-
Multiple threads should be able to read and write to the cache simultaneously.
-
Implement this using ConcurrentHashMap and ScheduledExecutorService for expiration handling.
-
-
Parallel Data Aggregation:
-
Calculate aggregate metrics (e.g., sum, average) on large datasets using parallel streams.
-
Experiment with different stream operations to optimize performance.
-
Measure and compare performance differences between parallel and sequential streams.
Examples2:
-
Calculate the total salary of all employees.
-
Calculate the average salary in each department.
-
Find the oldest employee in each department.
-
Find the highest-paid employee in the organization.
-
-
ForkJoinPoolQuestions Example 1: Recursive Merge Sort
- Implements the merge sort algorithm using ForkJoinPool.
- Divides the array into smaller segments, sorts them recursively, and merges the results.
- Demonstrates the efficiency of parallel processing for sorting large datasets
Example 2: Recursive Array Sum
- Calculates the sum of array elements using ForkJoinPool.
- Splits the array into smaller segments, computes the sum recursively, and combines the results.
- Highlights the benefits of parallel computation for aggregating data.
-
CyclicBarrierWithCustomActions
- Build a custom version of CyclicBarrier that allows threads to wait at a barrier until a certain number of threads reach it.
- Add a feature where, once the barrier is reached, a specified action (e.g. printing a message or resetting some variables) is performed.
-
BuildFaultTolerantMessageQueue
- Design a simple message queue that supports basic operations like enqueue, dequeue, and ack.
- Use multiple threads to simulate producers and consumers.
- Add fault tolerance so that if a message is dequeued but not acknowledged, it is re-queued for another attempt.
-
Parking Lot System
- Design a parking lot system with classes, relationships, and actions for managing parking and vehicle retrieval.
-
Task Pipeline
- Task Pipeline with State Design Pattern for File Data Fetching, Processing, and Saving (Synchronous).
- State Design Pattern: Ensures flexible transition between the stages of data handling.
- Synchronous Operation: The stages execute one after another without concurrency or parallel processing.
- Data Flow: Data is passed between stages using a BlockingQueue to ensure correct sequencing and avoid data loss.
- File Processing: Data is fetched from a file, processed (e.g., converted to uppercase), and then saved to another file. TaskPipeline
-
Json Parser
-
Custom Generic HashMap Implementation
- HashMap with Collision Handling
- Generic Hashmap with put, get and remove methods HashmapImpl
-
LRU Cache
- Easily adaptable cache design supporting custom eviction policies and storage backend CacheDesignImpl
-
Splitwise app
-
Vending Machine
-
TV
- TV State Management System using State Design Pattern TV
-
Book My show
-
Elevator
- Multi-Elevator System: An Extensible, Strategy-Driven Elevator Simulation with Priority Queuing Elevator
-
Cricbuzz live score
-
Calculator Service
- Advanced Calculator Service with Support for Basic and Scientific Operations
- Calculator service evaluates mathematical expressions with support for basic operations (+, -, *, /)
- trigonometric functions (e.g., sin, cos), and parentheses.
- Used Command and Interpreter design patterns for flexibility and extensibility CalculatorService
-
Java Stream part 1 JavaStream
-
Java Stream part 2 JavaStream2