Annotations
Paired
The paired annotation is used to force an annotation to be with another.
Add the annotation to another annotation.
@Paired(Field.class)
public @interface Foreign {
}This means you can only use the foreign annotation combined with the field annotation.
// Correct way of using your annotation.
public @Field @Foreign int number;
// This will now throw an error.
// You will need to implement the checker tho.
public @Foreign int number;To make sure the @Paired annotation works you will need to use the checker.
@Test
public void testPaired() {
boolean isUsedCorrectly = Paired.Checker.isUsedCorrectly("your.package");
if (!isUsedCorrectly) throw new Exception();
}This is an example of a JUnit test.
Last updated