net.sf.andromedaioc.bean.param.ValueParserFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of andromeda-ioc Show documentation
Show all versions of andromeda-ioc Show documentation
Inversion of Control Framework for Android
The newest version!
package net.sf.andromedaioc.bean.param;
import net.sf.andromedaioc.bean.wrapper.BeanWrapper;
import net.sf.andromedaioc.model.beans.ReferenceKey;
import net.sf.andromedaioc.model.beans.ValueModel;
import net.sf.andromedaioc.resource.ResourceProvider;
import java.util.Map;
/**
* Value parser factory
*
* @author Alexey Mitrov
*/
public class ValueParserFactory {
/**
* Get value parser based on value model provided
* @param valueModel value model we need parser for
* @param type type is needed for conversion
* @param beans beans for reference values
* @param resourceProvider resource provider for android and classpath resources loading
* @return value parser
*/
public static ValueParser getValueParser(ValueModel valueModel, Class> type, Map beans, ResourceProvider resourceProvider) {
if(valueModel.getType().isReference()) {
return new ReferenceValueParser(valueModel, type, beans);
} else if(valueModel.isPlaceHolder()) {
return new PlaceHolderValueParser(valueModel, type, resourceProvider);
} else if(valueModel.isResource()) {
return new ResourceValueParser(valueModel, type, resourceProvider);
} else if(valueModel.isProperty()) {
return new PropertyValueParser(valueModel, type, resourceProvider);
} else {
return new ConstantValueParser(valueModel, type);
}
}
}