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

com.github.bingoohuang.instantiator.BeanInstantiatorFactory Maven / Gradle / Ivy

There is a newer version: 0.0.34
Show newest version
package com.github.bingoohuang.instantiator;

import lombok.val;

import java.lang.reflect.Constructor;

public class BeanInstantiatorFactory {
    @SuppressWarnings("unchecked")
    public static  BeanInstantiator newBeanInstantiator(Class beanClass) {
        val ctors = (Constructor[]) beanClass.getConstructors();
        for (val ctor : ctors) {
            if (ctor.getParameterTypes().length == 0) {
                return new ConstructorBeanInstantiator(ctor);
            }
        }

        return new ObjenesisBeanInstantiator(beanClass);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy