Format annotation attributes
This commit is contained in:
parent
3a5fd90d14
commit
f12bcd2911
6 changed files with 275 additions and 16 deletions
14
testsuite/classes/java/CustomAnnotation.java
Normal file
14
testsuite/classes/java/CustomAnnotation.java
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
@CustomAnnotationAnnotation
|
||||
public @interface CustomAnnotation {
|
||||
public CustomAnnotationType type();
|
||||
|
||||
public String name() default "Bob";
|
||||
}
|
||||
|
||||
9
testsuite/classes/java/CustomAnnotationAnnotation.java
Normal file
9
testsuite/classes/java/CustomAnnotationAnnotation.java
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.ANNOTATION_TYPE)
|
||||
public @interface CustomAnnotationAnnotation { }
|
||||
|
||||
5
testsuite/classes/java/CustomAnnotationType.java
Normal file
5
testsuite/classes/java/CustomAnnotationType.java
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
public enum CustomAnnotationType {
|
||||
ONE,
|
||||
TWO,
|
||||
}
|
||||
|
||||
|
|
@ -4,7 +4,6 @@ import java.lang.annotation.Target;
|
|||
import java.lang.annotation.ElementType;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface CustomAttribute {
|
||||
}
|
||||
@Target(ElementType.PARAMETER)
|
||||
public @interface CustomParameterAnnotation { }
|
||||
|
||||
|
|
@ -1,11 +1,12 @@
|
|||
import java.util.function.Supplier;
|
||||
|
||||
@CustomAnnotation(type = CustomAnnotationType.ONE, name = "Alice")
|
||||
public class Main implements Runnable, Supplier<Integer>, Interface {
|
||||
private static final String name = "John";
|
||||
private static final int number = 42;
|
||||
private static final double funnyNumber = 6.9;
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(@CustomParameterAnnotation String[] args) {
|
||||
final var main = new Main();
|
||||
main.sayHello();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue