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

net.sf.andromedaioc.bean.param.ValueParserFactory Maven / Gradle / Ivy

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);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy