Record Class OrderDraft
java.lang.Object
java.lang.Record
com.example.orderplatform.orders.domain.OrderDraft
- Record Components:
customerId- customer placing the orderlines- priced order lines
Validated order draft created after pricing has accepted each requested line.
-
Constructor Summary
ConstructorsConstructorDescriptionOrderDraft(UUID customerId, List<OrderLineDraft> lines) Creates an instance of aOrderDraftrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecustomerIdrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.lines()Returns the value of thelinesrecord component.final StringtoString()Returns a string representation of this record class.total()Calculates the order total from all priced lines.
-
Constructor Details
-
OrderDraft
Creates an instance of aOrderDraftrecord class.- Parameters:
customerId- the value for thecustomerIdrecord componentlines- the value for thelinesrecord component
-
-
Method Details
-
total
Calculates the order total from all priced lines.- Returns:
- total monetary value
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
customerId
Returns the value of thecustomerIdrecord component.- Returns:
- the value of the
customerIdrecord component
-
lines
Returns the value of thelinesrecord component.- Returns:
- the value of the
linesrecord component
-