新增 DefinedIn 注解。

dev
ZhouXY108 2024-03-30 20:48:08 +08:00
parent 0b968e2c7b
commit b547642e5e
3 changed files with 82 additions and 0 deletions

25
pom.xml
View File

@ -132,4 +132,29 @@
</plugins> </plugins>
</pluginManagement> </pluginManagement>
</build> </build>
<repositories>
<repository>
<id>aliyun</id>
<url>https://maven.aliyun.com/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>aliyun-plugin</id>
<url>https://maven.aliyun.com/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project> </project>

View File

@ -0,0 +1,12 @@
package xyz.zhouxy.plusone.commons.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.SOURCE)
public @interface DefinedIn {
Class<?>[] value();
}

View File

@ -0,0 +1,45 @@
package xyz.zhouxy.plusone.commons.annotation;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
class ExplicitImplTest {
@Test
void test() {
}
}
interface A {
void fooA();
void fooAll();
}
interface B {
void fooB();
void fooAll();
}
class C implements A, B {
@DefinedIn(A.class)
@Override
public void fooA() {
}
@DefinedIn(B.class)
@Override
public void fooB() {
}
@DefinedIn({ A.class, B.class })
@Override
public void fooAll() {
}
}