Class CustomerOrder

java.lang.Object
de.calamanari.pk.visitor.CustomerOrder

public class CustomerOrder
extends java.lang.Object
Customer Order - each order can carry a special discount. This discount can be added to a company or division discount but it is not applicable to order items carrying a special promotion discount. Instead the higher discount will be chosen.
Author:
Karl Eilebrecht
  • Constructor Summary

    Constructors
    Constructor Description
    CustomerOrder​(java.lang.String contactPerson, CustomerDivision division, double specialDiscountPerc)
    Creates new order
  • Method Summary

    Modifier and Type Method Description
    void accept​(EnterpriseVisitor visitor)
    Method to accept enterprise visitor
    OrderItem addOrMergeOrderItem​(OrderItem item)
    Adds the order item and evtl. merges with existing one.
    The caller should always use the returned item because the item passed to this method may have been merged.
    In case of merge the attributes we use the smaller value for price and the higher value for discount (customer advantage rule :-) ).
    java.lang.String getContactPerson()
    Returns the contact person
    CustomerDivision getDivision()
    Returns the division
    java.util.List<OrderItem> getOrderItems()
    Returns an unmodifiable list of the order items assigned to this order
    double getSpecialDiscountPerc()
    Returns the special discount percentage value, to be applied to the value of this order
    void removeOrderItem​(OrderItem item)
    Removes the given item from the order
    void setContactPerson​(java.lang.String contactPerson)
    Sets the contact person
    void setDivision​(CustomerDivision division)
    Sets the division
    void setSpecialDiscountPerc​(double specialDiscountPerc)
    Sets the special discount percentage value, to be applied to the value of this order
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • CustomerOrder

      public CustomerOrder​(java.lang.String contactPerson, CustomerDivision division, double specialDiscountPerc)
      Creates new order
      Parameters:
      contactPerson - person related to order
      division - optional division the order belongs to
      specialDiscountPerc - order-related discount
  • Method Details

    • getDivision

      Returns the division
      Returns:
      division the order belongs to or null if no division is involved
    • setDivision

      public void setDivision​(CustomerDivision division)
      Sets the division
      Parameters:
      division - assigned divison
    • getContactPerson

      public java.lang.String getContactPerson()
      Returns the contact person
      Returns:
      contact person responsible for the order
    • setContactPerson

      public void setContactPerson​(java.lang.String contactPerson)
      Sets the contact person
      Parameters:
      contactPerson - order-related contact person
    • getSpecialDiscountPerc

      public double getSpecialDiscountPerc()
      Returns the special discount percentage value, to be applied to the value of this order
      Returns:
      discount
    • setSpecialDiscountPerc

      public void setSpecialDiscountPerc​(double specialDiscountPerc)
      Sets the special discount percentage value, to be applied to the value of this order
      Parameters:
      specialDiscountPerc - order-related discount
    • addOrMergeOrderItem

      Adds the order item and evtl. merges with existing one.
      The caller should always use the returned item because the item passed to this method may have been merged.
      In case of merge the attributes we use the smaller value for price and the higher value for discount (customer advantage rule :-) ).
      Parameters:
      item - order item to be added
      Returns:
      the added item
    • removeOrderItem

      public void removeOrderItem​(OrderItem item)
      Removes the given item from the order
      Parameters:
      item - the order item to be removed
    • getOrderItems

      public java.util.List<OrderItem> getOrderItems()
      Returns an unmodifiable list of the order items assigned to this order
      Returns:
      list of order items
    • accept

      public void accept​(EnterpriseVisitor visitor)
      Method to accept enterprise visitor
      Parameters:
      visitor - current visitor
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object