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

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

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

import java.util.HashMap;
import java.util.Map;

/**
 * Date: 2013/04/27
 * Time: 10:29 AM
 *
 */
public class UmlgTmpIdManager {

    public static UmlgTmpIdManager INSTANCE = new UmlgTmpIdManager();

    private UmlgTmpIdManager() {
    }

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

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

    public String get(Object id) {
        return idToFakeIdMap.get().get(id);
    }

    public Object get(String fakeId) {
        return fakeIdToIdMap.get().get(fakeId);
    }

    public void put(String fakeId, Object id) {
        fakeIdToIdMap.get().put(fakeId, id);
        idToFakeIdMap.get().put(id, fakeId);
    }

    public static void remove() {
        fakeIdToIdMap.remove();
        idToFakeIdMap.remove();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy