{"id":158,"date":"2017-01-17T16:00:00","date_gmt":"2017-01-17T07:00:00","guid":{"rendered":"https:\/\/java-code.jp\/?p=158"},"modified":"2017-01-17T16:00:10","modified_gmt":"2017-01-17T07:00:10","slug":"%e3%82%a2%e3%83%8e%e3%83%86%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%82%92%e5%88%a9%e7%94%a8%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/java-code.jp\/158","title":{"rendered":"\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u5229\u7528\u3059\u308b"},"content":{"rendered":"<p>\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u305d\u306e\u3082\u306e\u306f\u3001\u5358\u306a\u308b\u540d\u524d\u3068\u578b\u306e\u5b9a\u7fa9\u306b\u3059\u304e\u307e\u305b\u3093\u306e\u3067\u3001\u6307\u5b9a\u3055\u308c\u305f\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u306b\u5fdc\u3058\u3066\u3069\u306e\u3088\u3046\u306a\u51e6\u7406\u3092\u5b9f\u65bd\u3059\u308b\u304b\u3092\u6c7a\u3081\u308b\u306e\u306f\u3001\u547c\u3073\u51fa\u3057\u5143\u306e\u8cac\u4efb\u3067\u3059\u3002<br \/>\n\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u60c5\u5831\u306f\u3001Method#getAnnortation\u30e1\u30bd\u30c3\u30c9\u3067\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002Method\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u53d6\u5f97\u3059\u308b\u306e\u306f\u3001Class#getMethod\u30e1\u30bd\u30c3\u30c9\u306e\u5f79\u5272\u3067\u3059\u3002\uff08\u203b\uff09<\/p>\n<p><span class=\"small\">\u203b\u3053\u308c\u3089\u30af\u30e9\u30b9\u3084\u305d\u306e\u30e1\u30f3\u30d0\u30fc\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u305f\u3081\u306e\u6a5f\u80fd\u3092<span>\u30ea\u30d5\u30ec\u30af\u30b7\u30e7\u30f3<\/span>\u3068\u8a00\u3044\u307e\u3059\u3002<\/span><\/p>\n<p class=\"list\">AnnotationSample.java<\/p>\n<div class=\"pre\">\n<pre class=\"brush:java;\">\r\npackage com.example.mynavi.object;\r\n\r\nimport java.lang.reflect.Method;\r\n\r\npublic class AnnotationSample {\r\n  @Version(1.0)\r\n  public void annotationTest() {\r\n    System.out.println(\"Released\");\r\n  }\r\n\r\n  public static void main(String[] args) {\r\n    try {\r\n\t\t\t\/\/ annotationTest\u30e1\u30bd\u30c3\u30c9\u3092\u53d6\u5f97\r\n      Method m = AnnotationSample.class.getMethod(\"annotationTest\");\r\n\t\t\t\/\/ Version\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u53d6\u5f97\r\n      Version v = m.getAnnotation(Version.class);\r\n\t\t\t\/\/ Version\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u304c1.0\u4ee5\u4e0a\u306e\u5834\u5408\u306e\u307f\u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u884c\r\n      if (v.value() >= 1.0) {\r\n        m.invoke(AnnotationSample.class.newInstance());\r\n      }\r\n    } catch (Exception e) {\r\n      e.printStackTrace();\r\n    }\r\n  }\r\n}\r\n<\/pre>\n<p><!-- \/ .pre --><\/div>\n<p>\u3053\u306e\u4f8b\u3067\u3042\u308c\u3070\u3001\u53d6\u5f97\u3057\u305fValue\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u306e\u5024\u304c1.0\u4ee5\u4e0a\u306e\u5834\u5408\u306b\u3001\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u304c\u4ed8\u4e0e\u3055\u308c\u305f\u30e1\u30bd\u30c3\u30c9\uff08\u3053\u3053\u3067\u306fannotationTest\uff09\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002Method\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u7d4c\u7531\u3067\u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u306b\u306f\u3001invoke\u30e1\u30bd\u30c3\u30c9\u3092\u5229\u7528\u3057\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u305d\u306e\u3082\u306e\u306f\u3001\u5358\u306a\u308b\u540d\u524d\u3068\u578b\u306e\u5b9a\u7fa9\u306b\u3059\u304e\u307e\u305b\u3093\u306e\u3067\u3001\u6307\u5b9a\u3055\u308c\u305f\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u306b\u5fdc\u3058\u3066\u3069\u306e\u3088\u3046\u306a\u51e6\u7406\u3092\u5b9f\u65bd\u3059\u308b\u304b\u3092\u6c7a\u3081\u308b\u306e\u306f\u3001\u547c\u3073\u51fa\u3057\u5143\u306e\u8cac\u4efb\u3067\u3059\u3002 \u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u60c5\u5831\u306f\u3001Method#getAnnortati [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-158","post","type-post","status-publish","format-standard","hentry","category-annotation"],"_links":{"self":[{"href":"https:\/\/java-code.jp\/wp-json\/wp\/v2\/posts\/158"}],"collection":[{"href":"https:\/\/java-code.jp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/java-code.jp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/java-code.jp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/java-code.jp\/wp-json\/wp\/v2\/comments?post=158"}],"version-history":[{"count":2,"href":"https:\/\/java-code.jp\/wp-json\/wp\/v2\/posts\/158\/revisions"}],"predecessor-version":[{"id":1063,"href":"https:\/\/java-code.jp\/wp-json\/wp\/v2\/posts\/158\/revisions\/1063"}],"wp:attachment":[{"href":"https:\/\/java-code.jp\/wp-json\/wp\/v2\/media?parent=158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java-code.jp\/wp-json\/wp\/v2\/categories?post=158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java-code.jp\/wp-json\/wp\/v2\/tags?post=158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}