Class MaterialFactory
java.lang.Object
com.university.bookstore.factory.MaterialFactory
Factory class for creating Material instances.
Demonstrates the Factory pattern by providing a centralized
way to create different types of materials without exposing
their constructors directly.
This factory supports creating all material types including the new EBook class, with proper validation and error handling.
- Since:
- 2024-09-15
- Version:
- 2.0
- Author:
- Navid Mohaghegh
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
MaterialFactory
public MaterialFactory()
-
-
Method Details
-
createMaterial
Creates a Material instance based on the specified type and properties.- Parameters:
type- the material typeproperties- map of properties required for the material- Returns:
- the created Material instance
- Throws:
IllegalArgumentException- if type is null or properties are invalidNullPointerException- if required properties are missing
-