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

com.vwo.mobile.data.io.ObjectQueue Maven / Gradle / Ivy

There is a newer version: 2.7.0
Show newest version
// Copyright 2011 Square, Inc.
package com.vwo.mobile.data.io;

/**
 * A queue of objects.
 *
 * @param  The type of queue for the elements.
 */
public interface ObjectQueue {

    /**
     * Returns the number of entries in the queue.
     */
    int size();

    /**
     * Enqueues an entry that can be processed at any time.
     */
    void add(T entry);

    /**
     * Returns the head of the queue, or {@code null} if the queue is empty. Does not modify the
     * queue.
     */
    T peek();

    /**
     * Removes the head of the queue.
     */
    void remove();

    /**
     * Sets a listener on this queue. Invokes {@link Listener#onAdd} once for each entry that's
     * already in the queue. If an error occurs while reading the data, the listener will not receive
     * further notifications.
     */
    void setListener(Listener listener);

    /**
     * Listens for changes to the queue.
     *
     * @param  The type of elements in the queue.
     */
    interface Listener {

        /**
         * Called after an entry is added.
         */
        void onAdd(ObjectQueue queue, T entry);

        /**
         * Called after an entry is removed.
         */
        void onRemove(ObjectQueue queue);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy