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

com.github.ccob.bittrex4j.Observable Maven / Gradle / Ivy

There is a newer version: 1.0.12
Show newest version
/*
 * *
 *  This file is part of the bittrex4j project.
 *
 *  @author CCob
 *
 *  For the full copyright and license information, please view the LICENSE
 *  file that was distributed with this source code.
 * /
 */

package com.github.ccob.bittrex4j;

import com.github.ccob.bittrex4j.listeners.Listener;

import java.util.LinkedList;
import java.util.List;

public class Observable {

    private List> _observers =
            new LinkedList<>();

    public void addObserver(Listener obs) {
        if (obs == null) {
            throw new IllegalArgumentException("Tried to add a null observer");
        }
        if (_observers.contains(obs)) {
            return;
        }
        _observers.add(obs);
    }

    public void notifyObservers(ObservedType data) {
        for (Listener obs : _observers) {
            obs.onEvent(data);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy