io.github.kits.configuration.ConfigurationFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of whimthen-kits Show documentation
Show all versions of whimthen-kits Show documentation
Easy to use java tool library.
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;
}
}