@@ -0,0 +1,11 @@
|
||||
package com.reflectoring;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface CSV {
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.reflectoring;
|
||||
|
||||
public class TestMarkerAnnotation {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
XYZClient client = new XYZClient();
|
||||
Class clientClass = client.getClass();
|
||||
|
||||
if (clientClass.isAnnotationPresent(CSV.class)){
|
||||
System.out.println("Write client data to CSV.");
|
||||
} else {
|
||||
System.out.println("Write client data to Excel file.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.reflectoring;
|
||||
|
||||
@CSV
|
||||
public class XYZClient {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user