# Class MaterialEnhancementService

java.lang.Object
com.university.bookstore.decorator.MaterialEnhancementService

public class MaterialEnhancementService extends Object
Service for managing material enhancements using the Decorator pattern. Provides methods to apply various decorators to materials and create enhancement packages.

This service demonstrates the Decorator pattern in action by providing a high-level interface for dynamically adding features to materials.

Since:
  2024-09-15
Version:
  3.0
Author:
  Navid Mohaghegh

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MaterialEnhancementService()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Material`
  `addDigitalAnnotations(Material material)`
  Adds digital annotations to a material.
  `Material`
  `addExpeditedDelivery(Material material, int deliveryDays)`
  Adds expedited delivery to a material.
  `Material`
  `addGiftWrapping(Material material, String style)`
  Adds gift wrapping to a material.
  `double`
  `calculateEnhancementCost(Material original, Material enhanced)`
  Calculates the total enhancement cost for a material.
  `Material`
  `createDigitalPackage(Material material)`
  Creates a digital package with digital annotations (for e-books only).
  `Material`
  `createGiftPackage(Material material, String giftStyle, int deliveryDays)`
  Creates a gift package with gift wrapping and expedited delivery.
  `Material`
  `createPremiumPackage(Material material, String giftStyle, int deliveryDays)`
  Creates a premium package with multiple enhancements.
  `Material`
  `getBaseMaterial(Material material)`
  Gets the base material (unwraps all decorators).
  `double`
  `getBasePrice(Material material)`
  Gets the base price of a material (without decorators).
  `int`
  `getEnhancementCount(Material material)`
  Gets the number of decorators applied to a material.
  `String`
  `getEnhancementSummary(Material material)`
  Gets a summary of enhancements applied to a material.
  `boolean`
  `hasEnhancement(Material material, Class<? extends MaterialDecorator> enhancementType)`
  Checks if a material has a specific type of enhancement.
  `boolean`
  `hasEnhancements(Material material)`
  Checks if a material has any enhancements applied.
  `String`
  `toString()`

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

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

- ## Constructor Details

  - ### MaterialEnhancementService

    public MaterialEnhancementService()

- ## Method Details

  - ### addGiftWrapping

    public Material addGiftWrapping(Material material, String style)
    Adds gift wrapping to a material.
    Parameters:
      `material` - the material to enhance
      `style` - the wrapping style
    Returns:
      the enhanced material with gift wrapping
    Throws:
      `IllegalArgumentException` - if material or style is null

  - ### addExpeditedDelivery

    public Material addExpeditedDelivery(Material material, int deliveryDays)
    Adds expedited delivery to a material.
    Parameters:
      `material` - the material to enhance
      `deliveryDays` - the number of days for delivery
    Returns:
      the enhanced material with expedited delivery
    Throws:
      `IllegalArgumentException` - if material is null or deliveryDays is invalid

  - ### addDigitalAnnotations

    public Material addDigitalAnnotations(Material material)
    Adds digital annotations to a material.
    Parameters:
      `material` - the material to enhance
    Returns:
      the enhanced material with digital annotations
    Throws:
      `IllegalArgumentException` - if material is null

  - ### createPremiumPackage

    public Material createPremiumPackage(Material material, String giftStyle, int deliveryDays)
    Creates a premium package with multiple enhancements.
    Parameters:
      `material` - the material to enhance
      `giftStyle` - the gift wrapping style
      `deliveryDays` - the number of days for delivery
    Returns:
      the enhanced material with premium package
    Throws:
      `IllegalArgumentException` - if material is null or parameters are invalid

  - ### createGiftPackage

    public Material createGiftPackage(Material material, String giftStyle, int deliveryDays)
    Creates a gift package with gift wrapping and expedited delivery.
    Parameters:
      `material` - the material to enhance
      `giftStyle` - the gift wrapping style
      `deliveryDays` - the number of days for delivery
    Returns:
      the enhanced material with gift package

  - ### createDigitalPackage

    public Material createDigitalPackage(Material material)
    Creates a digital package with digital annotations (for e-books only).
    Parameters:
      `material` - the material to enhance
    Returns:
      the enhanced material with digital package, or original if not an e-book

  - ### calculateEnhancementCost

    public double calculateEnhancementCost(Material original, Material enhanced)
    Calculates the total enhancement cost for a material.
    Parameters:
      `original` - the original material
      `enhanced` - the enhanced material
    Returns:
      the total enhancement cost

  - ### getEnhancementSummary

    public String getEnhancementSummary(Material material)
    Gets a summary of enhancements applied to a material.
    Parameters:
      `material` - the material to analyze
    Returns:
      enhancement summary

  - ### getBasePrice

    public double getBasePrice(Material material)
    Gets the base price of a material (without decorators).
    Parameters:
      `material` - the material to analyze
    Returns:
      the base price

  - ### hasEnhancements

    public boolean hasEnhancements(Material material)
    Checks if a material has any enhancements applied.
    Parameters:
      `material` - the material to check
    Returns:
      true if enhancements are applied

  - ### getEnhancementCount

    public int getEnhancementCount(Material material)
    Gets the number of decorators applied to a material.
    Parameters:
      `material` - the material to analyze
    Returns:
      the decorator count

  - ### getBaseMaterial

    public Material getBaseMaterial(Material material)
    Gets the base material (unwraps all decorators).
    Parameters:
      `material` - the material to unwrap
    Returns:
      the base material

  - ### hasEnhancement

    public boolean hasEnhancement(Material material, Class<? extends MaterialDecorator> enhancementType)
    Checks if a material has a specific type of enhancement.
    Parameters:
      `material` - the material to check
      `enhancementType` - the type of enhancement to look for
    Returns:
      true if the enhancement is applied

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`