All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.paritytrading.parity.client.event.Events Maven / Gradle / Ivy

There is a newer version: 0.5.0
Show newest version
package com.paritytrading.parity.client.event;

import com.paritytrading.parity.net.poe.POE;
import com.paritytrading.parity.net.poe.POEClientListener;
import org.eclipse.collections.api.list.ImmutableList;
import org.eclipse.collections.impl.factory.Lists;

public class Events implements POEClientListener {

    private volatile ImmutableList events;

    public Events() {
        events = Lists.immutable.with();
    }

    public void accept(EventVisitor visitor) {
        for (Event event : events)
            event.accept(visitor);
    }

    @Override
    public void orderAccepted(POE.OrderAccepted message) {
        add(new Event.OrderAccepted(message));
    }

    @Override
    public void orderRejected(POE.OrderRejected message) {
        add(new Event.OrderRejected(message));
    }

    @Override
    public void orderExecuted(POE.OrderExecuted message) {
        add(new Event.OrderExecuted(message));
    }

    @Override
    public void orderCanceled(POE.OrderCanceled message) {
        add(new Event.OrderCanceled(message));
    }

    @Override
    public void brokenTrade(POE.BrokenTrade message) {
        add(new Event.BrokenTrade(message));
    }

    private void add(Event event) {
        events = events.newWith(event);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy