新增可获取重复性注解方法
This commit is contained in:
李鸿达
2022-04-26 17:35:43 +08:00
committed by Topcoder2023
parent d3f7fdcdd5
commit 562e77e438
3 changed files with 68 additions and 7 deletions

View File

@@ -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(){

View File

@@ -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 {
}