This file contains 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 todo; | |
public class ToDoTest { | |
@ToDo(message = "if文が不要なので1行にまとめる", expiration = "20160211") | |
public static boolean over5characters(String target) { | |
if (target.length() > 5) { | |
return true; | |
} |
This file contains 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 todo; | |
import javax.annotation.processing.*; | |
import javax.lang.model.SourceVersion; | |
import javax.lang.model.element.Element; | |
import javax.lang.model.element.TypeElement; | |
import javax.tools.Diagnostic.Kind; | |
import java.time.LocalDate; | |
import java.time.format.DateTimeFormatter; | |
import java.util.Set; |
This file contains 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 todo; | |
import java.lang.annotation.ElementType; | |
import java.lang.annotation.Retention; | |
import java.lang.annotation.RetentionPolicy; | |
import java.lang.annotation.Target; | |
@Target(ElementType.METHOD) | |
@Retention(RetentionPolicy.CLASS) | |
public @interface ToDo { |
This file contains 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 myannotation; | |
public class MyAnnotationTest { | |
@MyAnnotation | |
public String hoge; //←valueの値の指定をしていないのでデフォルト値 | |
@MyAnnotation(value = "コンストラクタ!!!") //←値を指定 | |
public MyAnnotationTest(String hoge) { | |
this.hoge = hoge; |
This file contains 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 myannotation; | |
import java.lang.annotation.ElementType; | |
import java.lang.annotation.Retention; | |
import java.lang.annotation.RetentionPolicy; | |
import java.lang.annotation.Target; | |
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR}) | |
@Retention(RetentionPolicy.RUNTIME) | |
public @interface MyAnnotation { |
This file contains 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 myannotation; | |
public class MyAnnotationTest { | |
@MyAnnotation //←こんなのとか | |
public String hoge; | |
@MyAnnotation(value = "コンストラクタ!!!") //←こんなのとか | |
public MyAnnotationTest(String hoge) { | |
this.hoge = hoge; |