Class AdvancedMaterialFactory

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

public class AdvancedMaterialFactory extends Object
Enhanced factory for creating Material instances with advanced validation and type-safe property extraction. Demonstrates improved Factory pattern implementation with better error handling and validation.

This factory extends the basic MaterialFactory with enhanced validation, type-safe property extraction, and support for complex material configurations.

Since:
2024-09-15
Version:
3.0
Author:
Navid Mohaghegh
  • Constructor Details

    • AdvancedMaterialFactory

      public AdvancedMaterialFactory()
  • 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
    • validateRequiredProperties

      public static void validateRequiredProperties(String type, Map<String,Object> properties)
      Validates that all required properties are present.
      Parameters:
      type - the material type to validate
      properties - the properties map to validate