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

org.umlg.runtime.adaptor.TransactionThreadNotificationVar Maven / Gradle / Ivy

There is a newer version: 2.0.15
Show newest version
package org.umlg.runtime.adaptor;

import org.umlg.runtime.notification.ChangeHolder;
import org.umlg.runtime.notification.NotificationListener;

import java.util.*;


public class TransactionThreadNotificationVar {

    private TransactionThreadNotificationVar() {
    }

    private static ThreadLocal>> transactionNotificationVar = new ThreadLocal>>() {
        @Override
        protected Map> initialValue() {
            return new HashMap<>();
        }
    };

    public static void remove() {
        transactionNotificationVar.get().clear();
        transactionNotificationVar.remove();
    }

    public static Map> get() {
        return transactionNotificationVar.get();
    }

    public static void add(NotificationListener notificationListener, ChangeHolder changeHolder) {
        List changeHolders = transactionNotificationVar.get().get(notificationListener);
        if (changeHolders == null) {
            changeHolders = new ArrayList<>();
            transactionNotificationVar.get().put(notificationListener, changeHolders);
        }
        changeHolders.add(changeHolder);
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy