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

plus.jdk.common.ReflectUtil Maven / Gradle / Ivy

package plus.jdk.common;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

public class ReflectUtil {

    /**
     * 判断某个对象是否继承自某接口
     */
    public static boolean isImplement(Object object, Class clazz) {
        Class[] interfaceArr = object.getClass().getInterfaces();
        boolean result = false;
        for (Class item : interfaceArr) {
            if (item == clazz) {
                result = true;
                break;
            }
        }
        return result;
    }

    public static boolean annotated(Object object, Class annotation) {
        if(object == null) {
            return false;
        }
        return object.getClass().getAnnotation(annotation) != null;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy