package com.paritytrading.parity.fix;

import java.util.ArrayList;
import java.util.List;

class Orders {

    private List<Order> orders;

    public Orders() {
        orders = new ArrayList<>();
    }

    public void add(Order order) {
        orders.add(order);
    }

    public Order findByClOrdID(String clOrdId) {
        for (int i = 0; i < orders.size(); i++) {
            Order order = orders.get(i);

            if (order.getClOrdID().equals(clOrdId))
                return order;
        }

        return null;
    }

    public Order findByOrigClOrdID(String origClOrdId) {
        for (int i = 0; i < orders.size(); i++) {
            Order order = orders.get(i);

            if (order.getOrigClOrdID().equals(origClOrdId))
                return order;
        }

        return null;
    }

    public Order findByOrderEntryID(String orderEntryId) {
        for (int i = 0; i < orders.size(); i++) {
            Order order = orders.get(i);

            if (order.getOrderEntryID().equals(orderEntryId))
                return order;
        }

        return null;
    }

    public void removeByOrderEntryID(String orderEntryId) {
        for (int i = 0; i < orders.size(); i++) {
            Order order = orders.get(i);

            if (order.getOrderEntryID().equals(orderEntryId)) {
                orders.remove(i);
                break;
            }
        }
    }

}

@@ -415,32 +415,47 @@
 %0A            if 
+(clOrdId.equals
 (order.getClOrdI
@@ -461,23 +461,8 @@
 ID()
-.equals(clOrdId
 ))%0A 
@@ -685,32 +685,51 @@
 %0A            if 
+(origClOrdId.equals
 (order.getOrigCl
@@ -739,27 +739,8 @@
 ID()
-.equals(origClOrdId
 ))%0A 
@@ -979,34 +979,23 @@
 f (order
-.getOrder
 EntryI
-D()
+d
 .equals(
@@ -999,23 +999,34 @@
 ls(order
+.getOrder
 EntryI
-d
+D()
 ))%0A     
@@ -1262,34 +1262,23 @@
 f (order
-.getOrder
 EntryI
-D()
+d
 .equals(
@@ -1282,23 +1282,34 @@
 ls(order
+.getOrder
 EntryI
-d
+D()
 )) %7B%0A   

Fix order cancellation in FIX gateway