mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-08-18 20:38:02 +08:00
新增可获取重复性注解方法
This commit is contained in:
@@ -3,7 +3,14 @@ package cn.hutool.core.annotation;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class AnnotationUtilTest {
|
||||
@Test
|
||||
public void getRepeatAnnotationValueTest(){
|
||||
Set<AnnotationForTest> annotations = AnnotationUtil.getRepeatedAnnotations(ClassWithAnnotation.class, AnnotationForTest.class);
|
||||
Assert.assertTrue(annotations != null && annotations.size() == 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAnnotationValueTest() {
|
||||
@@ -23,6 +30,7 @@ public class AnnotationUtilTest {
|
||||
}
|
||||
|
||||
@AnnotationForTest("测试")
|
||||
@RepeatAnnotationForTest
|
||||
static class ClassWithAnnotation{
|
||||
public void test(){
|
||||
|
||||
|
@@ -0,0 +1,16 @@
|
||||
package cn.hutool.core.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* @author hongda.li 2022-04-26 17:09
|
||||
*/
|
||||
@AnnotationForTest("repeat-annotation")
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
// Target注解决定MyAnnotation注解可以加在哪些成分上,如加在类身上,或者属性身上,或者方法身上等成分
|
||||
@Target({ ElementType.METHOD, ElementType.TYPE })
|
||||
public @interface RepeatAnnotationForTest {
|
||||
}
|
Reference in New Issue
Block a user