Skip to content

Instantly share code, notes, and snippets.

@keighty
Created January 8, 2017 22:47
Show Gist options
  • Save keighty/3827d1e132c88b059f5cc332fbbe6cad to your computer and use it in GitHub Desktop.
Save keighty/3827d1e132c88b059f5cc332fbbe6cad to your computer and use it in GitHub Desktop.
package com.keighty;
import java.lang.annotation.Documented;
@Documented
@interface CustomAnnotation {
int id();
String description();
String author() default "[unknown]";
}
package com.keighty;
import com.sun.istack.internal.NotNull;
public class Main {
@NotNull
private final String message;
public static void main(String[] args) {
Main main = new Main("This is a strong message");
main.printSlogan();
main.printBanner();
}
public Main(@NotNull String message) {
this.message = message;
}
@CustomAnnotation(id = 1, description = "Custom description")
public void printSlogan() {
System.out.println("This method uses a @CustomAnnotation");
}
@CustomAnnotation(id = 2, description = "Custom banner", author = "keighty")
public void printBanner() {
System.out.println("This is a printed banner for: " + message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment