This commit is contained in:
Looly
2025-09-05 17:23:06 +08:00
parent 175dd746ac
commit b6e7287287
9 changed files with 79 additions and 28 deletions

View File

@@ -97,7 +97,12 @@ public class AnnotationUtil {
// region ----- getAnnotation
/**
* 获取直接声明的注解,若已有缓存则从缓存中获取
* 获取直接声明的注解,若已有缓存则从缓存中获取,主要为:
* <ul>
* <li>只返回直接声明在该元素上的注解</li>
* <li>不包括从父类或接口继承来的注解</li>
* <li>只获取当前类/方法/字段等自身定义的注解</li>
* </ul>
*
* @param element {@link AnnotatedElement}
* @return 注解
@@ -108,7 +113,12 @@ public class AnnotationUtil {
}
/**
* 获取指定注解
* 获取指定注解,主要为:
* <ul>
* <li>返回该元素上的所有注解</li>
* <li>包括从父类或接口继承来的注解</li>
* <li>获取当前元素以及继承自父类或接口的所有注解</li>
* </ul>
*
* @param annotationEle {@link AnnotatedElement}可以是Class、Method、Field、Constructor、ReflectPermission
* @param isToCombination 是否为转换为组合注解,组合注解可以递归获取注解的注解

View File

@@ -342,8 +342,7 @@ public class HierarchicalAnnotatedElements implements AnnotatedElement, Iterable
scanHierarchy(mappings, (Class<?>)source, false, source);
}
// 原始元素是方法
else if (source instanceof Method) {
final Method methodSource = (Method)source;
else if (source instanceof final Method methodSource) {
// 静态、私有与被final关键字修饰方法无法被子类重写因此不可能具有层级结构
if (Modifier.isPrivate(methodSource.getModifiers())
|| Modifier.isFinal(methodSource.getModifiers())

View File

@@ -276,14 +276,14 @@ public enum Month {
/**
* 获得指定月的最后一天
*
* @param month 月份从0开始
* @param monthBase0 月份从0开始
* @param isLeapYear 是否为闰年,闰年只对二月有影响
* @return 最后一天可能为28,29,30,31
* @since 5.4.7
*/
public static int getLastDay(final int month, final boolean isLeapYear) {
final Month of = of(month);
Assert.notNull(of, "Invalid Month base 0: " + month);
public static int getLastDay(final int monthBase0, final boolean isLeapYear) {
final Month of = of(monthBase0);
Assert.notNull(of, "Invalid Month base 0: " + monthBase0);
return of.getLastDay(isLeapYear);
}