package com.paritytrading.philadelphia.client;

import com.paritytrading.philadelphia.FIXConnection;
import com.paritytrading.philadelphia.FIXConnectionStatusListener;
import com.paritytrading.philadelphia.FIXMessage;
import com.paritytrading.philadelphia.FIXMessageListener;
import java.util.ArrayList;
import java.util.List;

public class Messages implements FIXMessageListener, FIXConnectionStatusListener {

    private List<Message> messages;

    public Messages() {
        messages = new ArrayList<>();
    }

    public synchronized List<Message> collect() {
        return new ArrayList<>(messages);
    }

    @Override
    public void message(FIXMessage message) {
        add(message);
    }

    @Override
    public void close(FIXConnection connection, String message) {
    }

    @Override
    public void sequenceReset(FIXConnection connection) {
    }

    @Override
    public void tooLowMsgSeqNum(FIXConnection connection, long receivedMsgSeqNum, long expectedMsgSeqNum) {
    }

    @Override
    public void heartbeatTimeout(FIXConnection connection) {
    }

    @Override
    public void reject(FIXConnection connection, FIXMessage message) {
        add(message);
    }

    @Override
    public void logon(FIXConnection connection, FIXMessage message) {
        add(message);
    }

    @Override
    public void logout(FIXConnection connection, FIXMessage message) {
        add(message);
    }

    private void add(FIXMessage message) {
        add(Message.get(message));
    }

    private synchronized void add(Message message) {
        messages.add(message);
    }

}

@@ -321,23 +321,16 @@
 .List;%0A%0A
-public 
 class Me
@@ -439,23 +439,16 @@
 s;%0A%0A    
-public 
 Messages
@@ -501,23 +501,16 @@
  %7D%0A%0A    
-public 
 synchron

Clean up 'Messages'