Added Marker Annotation example (#148)

Added Marker Annotation example
This commit is contained in:
syedaf
2022-03-09 14:44:45 -05:00
committed by GitHub
parent 50f24940fd
commit c593aae6e1
3 changed files with 33 additions and 0 deletions

View File

@@ -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 {
}

View File

@@ -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.");
}
}
}

View File

@@ -0,0 +1,6 @@
package com.reflectoring;
@CSV
public class XYZClient {
}