001package com.ericlam.mc.eld.services;
002
003import javax.annotation.Nonnull;
004import javax.annotation.Nullable;
005import java.lang.annotation.Annotation;
006import java.lang.reflect.Field;
007import java.lang.reflect.Method;
008import java.lang.reflect.Parameter;
009import java.lang.reflect.Type;
010import java.util.List;
011
012/**
013 * 反射工具服務
014 */
015public interface ReflectionService {
016
017    /**
018     * 取得整個 class 上下關係的 declared fields
019     *
020     * @param startClass      開始類別
021     * @param exclusiveParent 到此父類別停止
022     * @return 整個 class 上下關係的 declared fields
023     */
024    List<Field> getDeclaredFieldsUpTo(@Nonnull Class<?> startClass, @Nullable Class<?> exclusiveParent);
025
026    /**
027     * 取得整個 class 上下關係的 declared methods
028     *
029     * @param startClass      開始類別
030     * @param exclusiveParent 到此父類別停止
031     * @return 整個 class 上下關係的 declared methods
032     */
033    List<Method> getDeclaredMethodsUpTo(@Nonnull Class<?> startClass, @Nullable Class<?> exclusiveParent);
034
035    /**
036     * 從快取獲取反射加快速度
037     * @param method 方法
038     * @return 標註列表
039     */
040    Annotation[] getDeclaredAnnotations(Method method);
041
042    /**
043     * 從快取獲取反射加快速度
044     * @param clazz 類別
045     * @return 類別標註列表
046     */
047    Annotation[] getDeclaredAnnotations(Class<?> clazz);
048
049    /**
050     * 從快取獲取反射加快速度
051     * @param clazz 類別
052     * @return 公共方法列表
053     */
054    Method[] getMethods(Class<?> clazz);
055
056    /**
057     * 從快取獲取反射加快速度
058     * @param method 方法
059     * @return 參數標註列表
060     */
061    Annotation[][] getParameterAnnotations(Method method);
062
063    /**
064     * 從快取獲取反射加快速度
065     * @param method 方法
066     * @return 參數類型列表
067     */
068    Type[] getParameterTypes(Method method);
069
070}