{"id":5005,"date":"2021-01-29T09:48:47","date_gmt":"2021-01-29T00:48:47","guid":{"rendered":"https:\/\/taki-lab.site\/bocci\/?p=5005"},"modified":"2021-01-29T09:49:00","modified_gmt":"2021-01-29T00:49:00","slug":"%e3%80%90%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%83%91%e3%82%bf%e3%83%bc%e3%83%b3%e3%80%91chain-of-responsibility%e3%83%91%e3%82%bf%e3%83%bc%e3%83%b3","status":"publish","type":"post","link":"https:\/\/taki-lab.site\/bocci\/?p=5005","title":{"rendered":"\u3010\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011Chain of Responsibility\u30d1\u30bf\u30fc\u30f3"},"content":{"rendered":"\n<p>Chain of Responsibility\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>package org.example.chainofresponsibility;\r\n\r\npublic class Question {\r\n    public int level;\r\n    public Question(int level){\r\n        this.level = level;\r\n    }\r\n}\r\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>package org.example.chainofresponsibility;\r\n\r\npublic abstract class Handler {\r\n    private Handler next;\r\n\r\n    public Handler setNext(Handler next)\r\n    {\r\n        this.next = next;\r\n        return next;\r\n    }\r\n\r\n    public final void request(Question question)\r\n    {\r\n        if(judge(question)) {\r\n            \/\/ \u51e6\u7406\u5b8c\u4e86\r\n        } else if(next != null) {\r\n            next.request(question);\r\n        } else {\r\n            \/\/ \u51e6\u7406\u4e0d\u53ef\u80fd\r\n        }\r\n    }\r\n\r\n    protected abstract boolean judge(Question question);\r\n}\r\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>package org.example.chainofresponsibility;\r\n\r\npublic class ConcreteHandler1 extends Handler {\r\n    @Override\r\n    protected boolean judge(Question question) {\r\n        if(question.level &lt;= 1) {\r\n            return true;\r\n        } else {\r\n            return false;\r\n        }\r\n    }\r\n}\r\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>package org.example.chainofresponsibility;\r\n\r\npublic class ConcreteHandler2 extends Handler{\r\n    @Override\r\n    protected boolean judge(Question question) {\r\n        if(question.level &lt;= 2) {\r\n            return true;\r\n        } else {\r\n            return false;\r\n        }\r\n    }\r\n}\r\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>package org.example.chainofresponsibility;\r\n\r\npublic class Main {\r\n    public static void main(String&#91;] args)\r\n    {\r\n        Handler handler1 = new ConcreteHandler1();\r\n        Handler handler2 = new ConcreteHandler2();\r\n\r\n        handler1.setNext(handler2);\r\n\r\n        Question question = new Question(1);\r\n\r\n        handler1.request(question);\r\n    }\r\n}\r\n<\/code><\/pre>\n\n\n\n<p>Chain of Responsibility\u306f\u51e6\u7406\u3092\u884c\u3046\u4eba(Handler)\u3092\u6570\u73e0\u3064\u306a\u304e\u306b\u914d\u5217\u3057\u3066\u304a\u304d\u3001\u30ea\u30af\u30a8\u30b9\u30c8(Question)\u306b\u5bfe\u3057\u3066\u5148\u982d\u306eHandler\u304b\u3089\u51e6\u7406\u304c\u53ef\u80fd\u304b\u3069\u3046\u304b\u3092\u5224\u5b9a(judge)\u3057\u3001\u51e6\u7406\u3067\u304d\u306a\u3044\u7269\u3067\u3042\u308c\u3070\u5f8c\u308d\u306eHandler\u306b\u307e\u308b\u6295\u3052\u3059\u308b\u3001\u3068\u3044\u3046\u4ed5\u7d44\u307f\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u306a\u306e\u3067\u3001\u3042\u3089\u304b\u3058\u3081Handler\u3092\u7d99\u627f\u3057\u3066\u3044\u308bConcreteHandler\u3092\u4f5c\u6210\u3057\u3066\u6570\u73e0\u3064\u306a\u304e\u3092\u4f5c\u3063\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>ConcreteHandler\u306b\u3066judge=true\u306a\u3089\u3070\u3001\u6e21\u3055\u308c\u305fquestion\u3092\u9069\u5207\u306b\u51e6\u7406\u3057\u3001judge=false\u306a\u3089\u3070\u3001\u305d\u306equestion\u3092\u5f8c\u308d\u306eConcreteHander\u306b\u6e21\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"\/\/blog.with2.net\/link\/?2023426:1010\" target=\"_blank\" rel=\"noreferrer noopener\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/taki-lab.site\/bocci\/wp-content\/uploads\/2019\/12\/03a6eee54039f74ded0b8f7548b1868f.png?w=474\" alt=\"\" title=\"\u30d1\u30bd\u30b3\u30f3\u30e9\u30f3\u30ad\u30f3\u30b0\"\/><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Chain of Responsibility\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u3059\u3002 Chain of Responsibility\u306f\u51e6\u7406\u3092\u884c\u3046\u4eba(Handler)\u3092\u6570\u73e0\u3064\u306a\u304e\u306b\u914d\u5217\u3057\u3066\u304a\u304d\u3001\u30ea\u30af\u30a8\u30b9\u30c8(Question)\u306b\u5bfe\u3057\u3066\u5148\u982d\u306e &hellip; <a href=\"https:\/\/taki-lab.site\/bocci\/?p=5005\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">\u3010\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011Chain of Responsibility\u30d1\u30bf\u30fc\u30f3<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"\u3010\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011Chain of Responsibility\u30d1\u30bf\u30fc\u30f3\n#TechCommit\n","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[225,3],"tags":[226],"class_list":["post-5005","post","type-post","status-publish","format-standard","hentry","category-225","category-3","tag-226"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8SDbY-1iJ","jetpack-related-posts":[{"id":6038,"url":"https:\/\/taki-lab.site\/bocci\/?p=6038","url_meta":{"origin":5005,"position":0},"title":"\u3010\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011Interpreter\u30d1\u30bf\u30fc\u30f3","author":"taki","date":"2021\u5e745\u67085\u65e5","format":false,"excerpt":"Interpreter\u30d1\u30bf\u30fc\u30f3\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3092\u307e\u3068\u3081\u3088\u3046\u3068\u601d\u3063\u305f\u306e\u3067\u3059\u304c\u30fb\u30fb\u30fb \u3046\u307e\u304f\u307e\u3068\u307e\u308a\u307e\u305b\u2026","rel":"","context":"\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3","block_context":{"text":"\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3","link":"https:\/\/taki-lab.site\/bocci\/?cat=225"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/taki-lab.site\/bocci\/wp-content\/uploads\/2021\/05\/ab1928778ad2239882c98e0fdd22b40d.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":4737,"url":"https:\/\/taki-lab.site\/bocci\/?p=4737","url_meta":{"origin":5005,"position":1},"title":"\u3010\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011Bridge\u30d1\u30bf\u30fc\u30f3","author":"taki","date":"2020\u5e7412\u670817\u65e5","format":false,"excerpt":"Bridge\u30d1\u30bf\u30fc\u30f3\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u3059\u3002 package org.example.bridge; \u2026","rel":"","context":"\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3","block_context":{"text":"\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3","link":"https:\/\/taki-lab.site\/bocci\/?cat=225"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":6568,"url":"https:\/\/taki-lab.site\/bocci\/?p=6568","url_meta":{"origin":5005,"position":2},"title":"\u3010\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011Iterator\u30d1\u30bf\u30fc\u30f3","author":"taki","date":"2021\u5e747\u670818\u65e5","format":false,"excerpt":"\u540c\u3058\u3088\u3046\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u6574\u5217\u3055\u305b\u3066\u7ba1\u7406\u3057\u305f\u3044\u3068\u304d\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002 \u30a4\u30e1\u30fc\u30b8\u3068\u3057\u3066\u306fLIST\u306b\u8fd1\u3044\u3002 p\u2026","rel":"","context":"\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3","block_context":{"text":"\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3","link":"https:\/\/taki-lab.site\/bocci\/?cat=225"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":8346,"url":"https:\/\/taki-lab.site\/bocci\/?p=8346","url_meta":{"origin":5005,"position":3},"title":"\u3010\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011Template Method\u30d1\u30bf\u30fc\u30f3","author":"taki","date":"2022\u5e745\u670815\u65e5","format":false,"excerpt":"Template Method\u30d1\u30bf\u30fc\u30f3\u306f\u3001\u6c7a\u307e\u308a\u5207\u3063\u3066\u3044\u308b\u51e6\u7406\u3092\u7e70\u308a\u8fd4\u3057\u4f7f\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u30d1\u30bf\u30fc\u30f3\u2026","rel":"","context":"\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3","block_context":{"text":"\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3","link":"https:\/\/taki-lab.site\/bocci\/?cat=225"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4776,"url":"https:\/\/taki-lab.site\/bocci\/?p=4776","url_meta":{"origin":5005,"position":4},"title":"\u3010\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011Composite\u30d1\u30bf\u30fc\u30f3","author":"taki","date":"2020\u5e7412\u670824\u65e5","format":false,"excerpt":"Composite\u30d1\u30bf\u30fc\u30f3\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u3059\u3002 package org.example.compo\u2026","rel":"","context":"\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3","block_context":{"text":"\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3","link":"https:\/\/taki-lab.site\/bocci\/?cat=225"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4588,"url":"https:\/\/taki-lab.site\/bocci\/?p=4588","url_meta":{"origin":5005,"position":5},"title":"\u3010\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011Builer\u30d1\u30bf\u30fc\u30f3","author":"taki","date":"2020\u5e7411\u670819\u65e5","format":false,"excerpt":"Builder\u30d1\u30bf\u30fc\u30f3\u306e\u30b3\u30fc\u30c9\u4f8b\u3067\u3059\u3002 package org.example.builder; p\u2026","rel":"","context":"\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3","block_context":{"text":"\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3","link":"https:\/\/taki-lab.site\/bocci\/?cat=225"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_likes_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/taki-lab.site\/bocci\/index.php?rest_route=\/wp\/v2\/posts\/5005","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/taki-lab.site\/bocci\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/taki-lab.site\/bocci\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/taki-lab.site\/bocci\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/taki-lab.site\/bocci\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5005"}],"version-history":[{"count":1,"href":"https:\/\/taki-lab.site\/bocci\/index.php?rest_route=\/wp\/v2\/posts\/5005\/revisions"}],"predecessor-version":[{"id":5006,"href":"https:\/\/taki-lab.site\/bocci\/index.php?rest_route=\/wp\/v2\/posts\/5005\/revisions\/5006"}],"wp:attachment":[{"href":"https:\/\/taki-lab.site\/bocci\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5005"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/taki-lab.site\/bocci\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5005"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/taki-lab.site\/bocci\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5005"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}