# Class MaterialFactory

java.lang.Object
com.university.bookstore.factory.MaterialFactory

public class MaterialFactory extends Object
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
  Constructor
  Description
  `MaterialFactory()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static Material`
  `createMaterial(String type, Map<String,Object> properties)`
  Creates a Material instance based on the specified type and properties.

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### MaterialFactory

    public MaterialFactory()

- ## Method Details

  - ### createMaterial

    public static Material createMaterial(String type, Map<String,Object> properties)
    Creates a Material instance based on the specified type and properties.
    Parameters:
      `type` - the material type
      `properties` - map of properties required for the material
    Returns:
      the created Material instance
    Throws:
      `IllegalArgumentException` - if type is null or properties are invalid
      `NullPointerException` - if required properties are missing