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

forklift.Registrar Maven / Gradle / Ivy

package forklift;

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

public class Registrar {
    protected List records = new ArrayList();

    public synchronized void register(T t) {
        records.add(t);
    }

    public synchronized T unregister(T t) {
        Iterator it = records.iterator();
        while (it.hasNext()) {
            T itT = it.next();
            if (itT.equals(t)) {
                it.remove();
                return itT;
            }
        }
        return null;
    }

    public synchronized boolean isRegistered(T t) {
        Iterator it = records.iterator();
        while (it.hasNext()) {
            T itT = it.next();
            if (itT.equals(t))
                return true;
        }
        return false;
    }

    public synchronized List getAll() {
        return records;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy