mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix code
This commit is contained in:
parent
82ef421e60
commit
a988a78868
@ -833,7 +833,7 @@ public class ClassUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>按广度优先遍历包括{@code root}在内,其层级结构中的所有类和接口。<br />
|
||||
* <p>按广度优先遍历包括{@code root}在内,其层级结构中的所有类和接口。<br>
|
||||
* 类遍历顺序如下:
|
||||
* <ul>
|
||||
* <li>离{@code type}距离越近,则顺序越靠前;</li>
|
||||
|
@ -125,7 +125,7 @@ public class MethodMatcherUtil {
|
||||
// region ============= 注解 =============
|
||||
|
||||
/**
|
||||
* <p>用于匹配被指定注解标注、或注解层级结构中存在指定注解的方法的方法匹配器。<br />
|
||||
* <p>用于匹配被指定注解标注、或注解层级结构中存在指定注解的方法的方法匹配器。<br>
|
||||
* 比如:指定注解为 {@code @Annotation},则匹配直接被{@code @Annotation}标注的方法。
|
||||
*
|
||||
* @param annotationType 注解类型
|
||||
@ -137,7 +137,7 @@ public class MethodMatcherUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>用于匹配被指定注解标注、或注解层级结构中存在指定注解的方法的方法匹配器。<br />
|
||||
* <p>用于匹配被指定注解标注、或注解层级结构中存在指定注解的方法的方法匹配器。<br>
|
||||
* 比如:指定注解为 {@code @Annotation},则匹配:
|
||||
* <ul>
|
||||
* <li>被{@code @Annotation}标注的方法;</li>
|
||||
@ -153,7 +153,7 @@ public class MethodMatcherUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>用于匹配声明方法的类的层级接口中,存在任意类被指定注解标注、或注解层级结构中存在指定注解的方法的方法匹配器。<br />
|
||||
* <p>用于匹配声明方法的类的层级接口中,存在任意类被指定注解标注、或注解层级结构中存在指定注解的方法的方法匹配器。<br>
|
||||
* 比如:指定注解为 {@code @Annotation},则匹配:
|
||||
* <ul>
|
||||
* <li>声明方法的类被{@code @Annotation}标注的方法;</li>
|
||||
@ -169,7 +169,7 @@ public class MethodMatcherUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>用于匹配方法本身或声明方法的类上,直接被指定注解标注、或注解层级结构中存在指定注解的方法的方法匹配器。<br />
|
||||
* <p>用于匹配方法本身或声明方法的类上,直接被指定注解标注、或注解层级结构中存在指定注解的方法的方法匹配器。<br>
|
||||
* 比如:指定注解为 {@code @Annotation},则匹配:
|
||||
* <ul>
|
||||
* <li>被{@code @Annotation}标注的方法;</li>
|
||||
@ -503,7 +503,7 @@ public class MethodMatcherUtil {
|
||||
* </ul>
|
||||
* </li>
|
||||
* </ul>
|
||||
* 比如:<br />
|
||||
* 比如:<br>
|
||||
* 若存在三参数方法{@code method(String, Integer, Object)},支持以下匹配:
|
||||
* <ul>
|
||||
* <li>{@code forMostSpecificParameterTypes(CharSequence.class, Number.class, Object.class)}</li>
|
||||
@ -535,7 +535,7 @@ public class MethodMatcherUtil {
|
||||
* </ul>
|
||||
* </li>
|
||||
* </ul>
|
||||
* 比如:<br />
|
||||
* 比如:<br>
|
||||
* 若存在三参数方法{@code method(String, Integer, Object)},支持以下匹配:
|
||||
* <ul>
|
||||
* <li>{@code forMostSpecificParameterTypes(String.class, Integer.class, Object.class)}</li>
|
||||
|
@ -33,9 +33,9 @@ import java.util.function.Predicate;
|
||||
* 若我们希望获得类所有方法范围中首个匹配的方法,则应当调用{@link #getFromAllMethods}。
|
||||
*
|
||||
* <p><strong>匹配规则</strong>
|
||||
* <p>方法查找的规则由{@link MethodMetadataLookup}实现。<br />
|
||||
* 规定,当{@link MethodMetadataLookup#inspect(Method)}方法返回元数据不为{@code null}时,则认为方法与其匹配,返回结果时将同时返回匹配的方法与元数据。<br />
|
||||
* 因此,我们可以通过实现{@link MethodMetadataLookup}接口来同时实现方法的查找与元数据的获取:<br />
|
||||
* <p>方法查找的规则由{@link MethodMetadataLookup}实现。<br>
|
||||
* 规定,当{@link MethodMetadataLookup#inspect(Method)}方法返回元数据不为{@code null}时,则认为方法与其匹配,返回结果时将同时返回匹配的方法与元数据。<br>
|
||||
* 因此,我们可以通过实现{@link MethodMetadataLookup}接口来同时实现方法的查找与元数据的获取:<br>
|
||||
* 比如,我们希望查找所有方法上带有{@code Annotation}注解的方法,则可以实现如下:
|
||||
* <pre>{@code
|
||||
* Map<Method, Annotation> methods = MethodScanner.findFromAllMethods(Foo.class, method -> method.getAnnotation(Annotation.class));
|
||||
@ -51,9 +51,9 @@ import java.util.function.Predicate;
|
||||
* <p><strong>缓存</strong>
|
||||
* <p>对于{@link #getDeclaredMethods}与{@link #getMethods}方法与基于这两个方法实现的,
|
||||
* 所有{@code xxxFromMethods}与{@code xxxFromDeclaredMethods}方法,
|
||||
* 都提供了缓存基于{@link WeakConcurrentMap}的缓存支持。<br />
|
||||
* 都提供了缓存基于{@link WeakConcurrentMap}的缓存支持。<br>
|
||||
* {@link #getAllMethods}与所有{@code xxxFromAllMethods}方法都基于{@link #getDeclaredMethods}实现,
|
||||
* 但是每次全量查找,都需要重新遍历类层级结构,因此会带来一定的额外的性能损耗。<br />
|
||||
* 但是每次全量查找,都需要重新遍历类层级结构,因此会带来一定的额外的性能损耗。<br>
|
||||
* 缓存在GC时会被回收,但是也可以通过{@link #clearCaches}手动清除缓存。
|
||||
*
|
||||
* @author huangchengxing
|
||||
|
Loading…
x
Reference in New Issue
Block a user