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

io.github.resilience4j.core.ClassUtils Maven / Gradle / Ivy

Go to download

Resilience4j is a lightweight, easy-to-use fault tolerance library designed for Java8 and functional programming

There is a newer version: 2.2.0
Show newest version
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> clazz) {
        try {
            Constructor 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