Class DiscountRequest
java.lang.Object
com.university.bookstore.chain.DiscountRequest
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
ConstructorsConstructorDescriptionDiscountRequest(Material material, double requestedDiscount, String customerId, String reason) Creates a new discount request. -
Method Summary
Modifier and TypeMethodDescriptionbooleanGets who approved the request.Gets the customer ID.doubleCalculates the discounted price if approved.Gets the material for which discount is requested.Gets the reason for the discount request.Gets the rejection reason.doubleGets the requested discount rate.doubleGets the requested discount percentage.doubleCalculates the savings amount if approved.Gets a summary of the discount request.longGets the request timestamp.inthashCode()booleanChecks if the request is approved.voidsetApproved(boolean approved) Sets the approval status.voidsetApprovedBy(String approvedBy) Sets who approved the request.voidsetRejectionReason(String rejectionReason) Sets the rejection reason.toString()
-
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 requestedrequestedDiscount- the requested discount rate (0.0 to 1.0)customerId- the customer requesting the discountreason- the reason for the discount request- Throws:
IllegalArgumentException- if parameters are invalid
-
-
Method Details
-
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
-
getReason
-
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
-
setApprovedBy
Sets who approved the request.- Parameters:
approvedBy- the approver name
-
getRejectionReason
-
setRejectionReason
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
-
equals
-
hashCode
-
toString
-