新增 DefinedIn 注解。

This commit is contained in:
2024-03-30 20:48:08 +08:00
parent 0b968e2c7b
commit b547642e5e
3 changed files with 82 additions and 0 deletions

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