com.ibm.commerce.marketing.promotion.runtime

Class LineItemSet

  • java.lang.Object
    • com.ibm.commerce.marketing.promotion.runtime.LineItemSet
  • All Implemented Interfaces:
    XMLizable, java.io.Serializable, java.lang.Cloneable


    public class LineItemSet
    extends java.lang.Object
    implements java.io.Serializable, XMLizable, java.lang.Cloneable
    This class represents a set of LineItems. The LineItemSet object can be created as a list of AssociatedOrderItem. It is a temporary grouping of order items used by the promotion engine during promotion evaluation.

    XML Snippet for LineItemSet:

      <LineItemSet>
            <AssociatedOrderItem impl="com.ibm.commerce.marketing.promotion.runtime.AssociatedOrderItem" >
                    <OrderItemKey>
                            <OrderItemId>1234</OrderItemId>
                    </OrderItemKey>
                    <StartIndex>2</StartIndex>
                    <Quantity>4</Quantity>
            </AssociatedOrderItem>
            <AssociatedOrderItem impl="com.ibm.commerce.marketing.promotion.runtime.AssociatedOrderItem" >
                    <OrderItemKey>
                            <OrderItemId>3456</OrderItemId>
                    </OrderItemKey>
                    <StartIndex>1</StartIndex>
                    <Quantity>9</Quantity>
            </AssociatedOrderItem>
      </LineItemSet>
      
     
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String COPYRIGHT
      IBM Copyright
    • Constructor Summary

      Constructors 
      Constructor and Description
      LineItemSet()
      Constructor
      LineItemSet(Order order)
      Constructor constructs a LineItemSet based on an order
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void addLineItem(AssociatedOrderItem anItem)
      Adds an AssociatedOrderItem to this LineItemSet; merge it with associated order items already in the set if possible
      java.lang.Object clone() 
      LineItemSet difference(LineItemSet that)
      Returns the difference between two line item sets by returning a new line item set representing their difference
      void directlyAppendItem(AssociatedOrderItem anItem)
      Append items without testing if this item can be merged with other items already in the line item set.
      void fromXML(org.w3c.dom.Node node)
      Builds an LineItem object from an XML fragment.
      AssociatedOrderItem[] getAssociatedOrderItems()
      Returns all the associated order items in an array
      java.math.BigDecimal getCost()
      Returns the total cost of all the associated items in this line item set.
      static java.util.Comparator getOrderItemComparator()
      Returns the order item comparator used by this LineItemSet
      boolean getOrderSplitEndToStart()
      Returns true if split order is end to start, otherwise false
      java.math.BigDecimal getQuantity()
      Returns the total quantity of all the associated items in this line item set.
      boolean hasCrossSection(LineItemSet that)
      Checks if two line item sets have a cross-section
      LineItemSet merge(LineItemSet that)
      Merges two line item sets
      static void setOrderItemComparator(java.util.Comparator comparator)
      Sets the order item comparator for this line item set
      void setOrderSplitEndToStart(boolean _orderSplitEndToStart)
      Sets the split order for this line item set
      LineItemSet[] split(java.math.BigDecimal[] quantities)
      Splits a line item set based on the quantities specified in the parameter.
      java.lang.String toXML()
      Generates XML fragments for this LineItem object
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • COPYRIGHT

        public static final java.lang.String COPYRIGHT
        IBM Copyright
        See Also:
        Constant Field Values
    • Constructor Detail

      • LineItemSet

        public LineItemSet()
        Constructor
      • LineItemSet

        public LineItemSet(Order order)
        Constructor constructs a LineItemSet based on an order
        Parameters:
        order - the order for constructing a LineItemSet
    • Method Detail

      • directlyAppendItem

        public void directlyAppendItem(AssociatedOrderItem anItem)
        Append items without testing if this item can be merged with other items already in the line item set.
        Parameters:
        anItem - item to be appended
      • addLineItem

        public void addLineItem(AssociatedOrderItem anItem)
        Adds an AssociatedOrderItem to this LineItemSet; merge it with associated order items already in the set if possible
        Parameters:
        anItem - item to be added
      • merge

        public LineItemSet merge(LineItemSet that)
        Merges two line item sets
        Parameters:
        that - the set to be merged with this set
        Returns:
        a new set that's the merged result of two line item sets
      • hasCrossSection

        public boolean hasCrossSection(LineItemSet that)
        Checks if two line item sets have a cross-section
        Parameters:
        that - line item set
        Returns:
        true if there is a cross-section, false otherwise
      • getAssociatedOrderItems

        public AssociatedOrderItem[] getAssociatedOrderItems()
        Returns all the associated order items in an array
        Returns:
        an array of all the associated order items in this line item set.
      • getQuantity

        public java.math.BigDecimal getQuantity()
        Returns the total quantity of all the associated items in this line item set.
        Returns:
        total quantity of all the associated items in this line item set.
      • getCost

        public java.math.BigDecimal getCost()
        Returns the total cost of all the associated items in this line item set.
        Returns:
        the total cost of all the associated items in this line item set.
      • difference

        public LineItemSet difference(LineItemSet that)
        Returns the difference between two line item sets by returning a new line item set representing their difference
        Parameters:
        that - another line item set
        Returns:
        the difference between two line item sets
      • split

        public LineItemSet[] split(java.math.BigDecimal[] quantities)
        Splits a line item set based on the quantities specified in the parameter. The split starts from the front of LineItemSet if splitEndToStart is false otherwise the split starts from the end. If the sum of all quantities in the quantities array is smaller than that of the line item set, quantities.length+1 sets will be returned. Otherwise quantities.length line item sets will be returned.
        Parameters:
        quantities - based on which quantities to split this line item set
        Returns:
        split results of line item set
      • getOrderSplitEndToStart

        public boolean getOrderSplitEndToStart()
        Returns true if split order is end to start, otherwise false
        Returns:
        orderSplitEndToStart
      • setOrderSplitEndToStart

        public void setOrderSplitEndToStart(boolean _orderSplitEndToStart)
        Sets the split order for this line item set
        Parameters:
        _orderSplitEndToStart - the orderSplitEndToStart to be set
      • getOrderItemComparator

        public static java.util.Comparator getOrderItemComparator()
        Returns the order item comparator used by this LineItemSet
        Returns:
        OrderItemComparator
      • setOrderItemComparator

        public static void setOrderItemComparator(java.util.Comparator comparator)
        Sets the order item comparator for this line item set
        Parameters:
        comparator - the OrderItemComparator to be set
      • fromXML

        public void fromXML(org.w3c.dom.Node node)
                     throws DeXMLizationException
        Builds an LineItem object from an XML fragment.
        Specified by:
        fromXML in interface XMLizable
        Parameters:
        node - Node the XML fragment
        Throws:
        DeXMLizationException - exception that may be caught in DeXMLization
      • toXML

        public java.lang.String toXML()
                               throws XMLizationException
        Generates XML fragments for this LineItem object
        Specified by:
        toXML in interface XMLizable
        Returns:
        the generated XML fragment
        Throws:
        XMLizationException - exception that may be caught in XMLization
      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException
        Overrides:
        clone in class java.lang.Object
        Throws:
        java.lang.CloneNotSupportedException
        See Also:
        Object.clone()