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

io.github.kits.configuration.ConfigurationFactory Maven / Gradle / Ivy

The newest version!
package io.github.kits.configuration;

/**
 * @project: kits
 * @created: with IDEA
 * @author: nzlong
 * @Date: 2019 01 23 13:50 | January. Wednesday
 */
public class ConfigurationFactory {

    public static ValueConfiguration createConfiguration(Class type) {
        ValueConfiguration configuration;
        if (String.class.isAssignableFrom(type)) {
            configuration = new StringValueConfiguration();
        } else if (Integer.class.isAssignableFrom(type) || int.class.isAssignableFrom(type)) {
            configuration = new IntValueConfiguration();
        } else if (Boolean.class.isAssignableFrom(type) || boolean.class.isAssignableFrom(type)) {
            configuration = new BooleanValueConfiguration();
        } else if (Long.class.isAssignableFrom(type) || long.class.isAssignableFrom(type)) {
            configuration = new LongValueConfiguration();
        } else if (Short.class.isAssignableFrom(type) || short.class.isAssignableFrom(type)) {
            configuration = new ShortValueConfiguration();
        } else if (Float.class.isAssignableFrom(type) || float.class.isAssignableFrom(type)) {
            configuration = new FloatValueConfiguration();
        } else if (Double.class.isAssignableFrom(type) || double.class.isAssignableFrom(type)) {
            configuration = new DoubleValueConfiguration();
        } else {
            configuration = new PropValueConfiguration();
        }
        return configuration;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy