Created
January 8, 2017 22:47
-
-
Save keighty/3827d1e132c88b059f5cc332fbbe6cad to your computer and use it in GitHub Desktop.
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
package com.keighty; | |
import java.lang.annotation.Documented; | |
@Documented | |
@interface CustomAnnotation { | |
int id(); | |
String description(); | |
String author() default "[unknown]"; | |
} |
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
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