io.github.resilience4j.core.ClassUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of resilience4j-core Show documentation
Show all versions of resilience4j-core Show documentation
Resilience4j is a lightweight, easy-to-use fault tolerance library designed for Java8 and functional programming
package io.github.resilience4j.core;
import io.github.resilience4j.core.lang.Nullable;
import java.lang.reflect.Constructor;
import java.util.function.Predicate;
public class ClassUtils {
@Nullable
@SuppressWarnings("unchecked")
public static Predicate instantiatePredicateClass(Class extends Predicate> clazz) {
try {
Constructor extends Predicate> c = clazz.getConstructor();
if (c != null) {
return c.newInstance();
} else {
throw new InstantiationException("Unable to create instance of class: " + clazz.getName());
}
} catch (Exception e) {
throw new InstantiationException("Unable to create instance of class: " + clazz.getName(), e);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy