Created
March 14, 2012 08:31
-
-
Save peter-lawrey/2035106 to your computer and use it in GitHub Desktop.
A way to associate code with an annotation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.annotation.Retention; | |
import java.lang.annotation.RetentionPolicy; | |
import java.lang.reflect.Member; | |
/** | |
* @author peter.lawrey | |
*/ | |
@Retention(RetentionPolicy.RUNTIME) | |
public @interface CustomAnnotation { | |
public int value() default 0; | |
enum HandlesAnnotation implements AnnotationHandler<CustomAnnotation> { | |
INSTANCE; | |
@Override | |
public void process(Model model, Member member, CustomAnnotation ca) { | |
// do something with a model based on the members details and the annotation state. | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment