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

com.talk2object.plum.interaction.viewgeneneration.ModelAdapterRegistry Maven / Gradle / Ivy

There is a newer version: 0.1.22
Show newest version
package com.talk2object.plum.interaction.viewgeneneration;

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

import org.apache.log4j.Logger;

public class ModelAdapterRegistry {
	
	private static final Logger logger = Logger.getLogger(ModelAdapterRegistry.class);
	
	
	// model class, 
	private Map> map = new HashMap>();

	private Map getBizAdapterFactorys(
			Class modelClass, boolean createIfNull) {
		Map value = map.get(modelClass);
		if (value == null && createIfNull) {
			value = new HashMap();
			map.put(modelClass, value);
		}
		return value;
	}

	public void add(ModelAdapterFactory maf) {
		getBizAdapterFactorys(maf.getTargetClass(), true).put(
				maf.getAdapteeClass(), maf);
	}

	public ModelAdapterFactory getModelAdapterFactory(Class modelClass,
			Class bizClass) {
		Map bizFactoryMap = map.get(modelClass);
		if (bizFactoryMap != null) {
			ModelAdapterFactory factory = bizFactoryMap.get(bizClass);
			return factory;
		}
		return null;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy