# Class DiscountRequest

java.lang.Object
com.university.bookstore.chain.DiscountRequest

public class DiscountRequest extends Object
Request object for discount approval in the Chain of Responsibility pattern. Contains all information needed to process a discount request.

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

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DiscountRequest(Material material, double requestedDiscount, String customerId, String reason)`
  Creates a new discount request.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object obj)`
  `String`
  `getApprovedBy()`
  Gets who approved the request.
  `String`
  `getCustomerId()`
  Gets the customer ID.
  `double`
  `getDiscountedPrice()`
  Calculates the discounted price if approved.
  `Material`
  `getMaterial()`
  Gets the material for which discount is requested.
  `String`
  `getReason()`
  Gets the reason for the discount request.
  `String`
  `getRejectionReason()`
  Gets the rejection reason.
  `double`
  `getRequestedDiscount()`
  Gets the requested discount rate.
  `double`
  `getRequestedDiscountPercentage()`
  Gets the requested discount percentage.
  `double`
  `getSavingsAmount()`
  Calculates the savings amount if approved.
  `String`
  `getSummary()`
  Gets a summary of the discount request.
  `long`
  `getTimestamp()`
  Gets the request timestamp.
  `int`
  `hashCode()`
  `boolean`
  `isApproved()`
  Checks if the request is approved.
  `void`
  `setApproved(boolean approved)`
  Sets the approval status.
  `void`
  `setApprovedBy(String approvedBy)`
  Sets who approved the request.
  `void`
  `setRejectionReason(String rejectionReason)`
  Sets the rejection reason.
  `String`
  `toString()`

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

  `getClass, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### DiscountRequest

    public DiscountRequest(Material material, double requestedDiscount, String customerId, String reason)
    Creates a new discount request.
    Parameters:
      `material` - the material for which discount is requested
      `requestedDiscount` - the requested discount rate (0.0 to 1.0)
      `customerId` - the customer requesting the discount
      `reason` - the reason for the discount request
    Throws:
      `IllegalArgumentException` - if parameters are invalid

- ## Method Details

  - ### getMaterial

    public Material getMaterial()
    Gets the material for which discount is requested.
    Returns:
      the material

  - ### getRequestedDiscount

    public double getRequestedDiscount()
    Gets the requested discount rate.
    Returns:
      the discount rate (0.0 to 1.0)

  - ### getRequestedDiscountPercentage

    public double getRequestedDiscountPercentage()
    Gets the requested discount percentage.
    Returns:
      the discount percentage (0.0 to 100.0)

  - ### getCustomerId

    public String getCustomerId()
    Gets the customer ID.
    Returns:
      the customer ID

  - ### getReason

    public String getReason()
    Gets the reason for the discount request.
    Returns:
      the reason

  - ### isApproved

    public boolean isApproved()
    Checks if the request is approved.
    Returns:
      true if approved

  - ### setApproved

    public void setApproved(boolean approved)
    Sets the approval status.
    Parameters:
      `approved` - the approval status

  - ### getApprovedBy

    public String getApprovedBy()
    Gets who approved the request.
    Returns:
      the approver name

  - ### setApprovedBy

    public void setApprovedBy(String approvedBy)
    Sets who approved the request.
    Parameters:
      `approvedBy` - the approver name

  - ### getRejectionReason

    public String getRejectionReason()
    Gets the rejection reason.
    Returns:
      the rejection reason

  - ### setRejectionReason

    public void setRejectionReason(String rejectionReason)
    Sets the rejection reason.
    Parameters:
      `rejectionReason` - the rejection reason

  - ### getTimestamp

    public long getTimestamp()
    Gets the request timestamp.
    Returns:
      the timestamp in milliseconds

  - ### getDiscountedPrice

    public double getDiscountedPrice()
    Calculates the discounted price if approved.
    Returns:
      the discounted price

  - ### getSavingsAmount

    public double getSavingsAmount()
    Calculates the savings amount if approved.
    Returns:
      the savings amount

  - ### getSummary

    public String getSummary()
    Gets a summary of the discount request.
    Returns:
      the request summary

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Object`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### toString

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