com.qwlabs.test.builders.BuilderAware Maven / Gradle / Ivy
The newest version!
package com.qwlabs.test.builders;
import com.qwlabs.cdi.SafeCDI;
public final class BuilderAware {
private BuilderAware() {
}
public static B getBuilder(Class builderClazz) {
return SafeCDI.current()
.map(cdi -> cdi.select(builderClazz).get())
.orElseGet(() -> {
try {
return builderClazz.newInstance();
} catch (Exception e) {
throw new RuntimeException("Can not found builder. class=" + builderClazz.getName());
}
});
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy