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

com.github.leeonky.jfactory.DefaultValueFactory Maven / Gradle / Ivy

The newest version!
package com.github.leeonky.jfactory;

import com.github.leeonky.util.BeanClass;

import static java.lang.String.format;

public interface DefaultValueFactory {
     V create(BeanClass beanType, SubInstance instance);

    @SuppressWarnings("unchecked")
    default Class getType() {
        return (Class) BeanClass.create(getClass()).getSuper(DefaultValueFactory.class).getTypeArguments(0)
                .orElseThrow(() -> new IllegalStateException(format("Cannot guess type `%s` via generic type argument,"
                        + " please override DefaultValueFactory::getType", getClass().getName())))
                .getType();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy