Skip to content

Commit c593aae

Browse files
authored
Added Marker Annotation example (thombergs#148)
Added Marker Annotation example
1 parent 50f2494 commit c593aae

3 files changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.reflectoring;
2+
3+
import java.lang.annotation.ElementType;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.RetentionPolicy;
6+
import java.lang.annotation.Target;
7+
8+
@Target(ElementType.TYPE)
9+
@Retention(RetentionPolicy.RUNTIME)
10+
public @interface CSV {
11+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.reflectoring;
2+
3+
public class TestMarkerAnnotation {
4+
5+
public static void main(String[] args) {
6+
7+
XYZClient client = new XYZClient();
8+
Class clientClass = client.getClass();
9+
10+
if (clientClass.isAnnotationPresent(CSV.class)){
11+
System.out.println("Write client data to CSV.");
12+
} else {
13+
System.out.println("Write client data to Excel file.");
14+
}
15+
}
16+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.reflectoring;
2+
3+
@CSV
4+
public class XYZClient {
5+
6+
}

0 commit comments

Comments
 (0)