package com.hammurapi.common.concurrent;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

import com.hammurapi.common.Context;
import com.hammurapi.convert.Converter;

/**
 * Property set which uses in-memory collections and reentrant read-write lock
 * @author Pavel Vlasov
 *
 * @param <KP>
 * @param <KE>
 */
public abstract class LocalAbstractPropertySet<KP, KE> extends AbstractPropertySet<KP, KE> {

	private Map<KE, Object> valueStore = new HashMap<KE, Object>();
	private Map<KE, AbstractPropertySet<KP, KE>> subSetStore = new HashMap<KE, AbstractPropertySet<KP,KE>>();
	private Map<KE, PropertySet<KP>> mounts = new HashMap<KE, PropertySet<KP>>();

	protected LocalAbstractPropertySet(
			ExecutorService executorService,
			Converter converter, 
//			ClassLoader classLoader,
			Context context,			
			PropertySet<KP>... shadows) {
		super(executorService, converter, /* classLoader,*/ context, shadows);
	}

	@Override
	protected Map<KE, Object> getValueStore() {
		return valueStore;
	}

	@Override
	protected Map<KE, AbstractPropertySet<KP, KE>> getSubSetStore() {
		return subSetStore;
	}

	@Override
	protected Map<KE, PropertySet<KP>> getMounts() {
		return mounts;
	}

}
