{"id":8205,"date":"2022-04-25T14:47:00","date_gmt":"2022-04-25T05:47:00","guid":{"rendered":"https:\/\/taki-lab.site\/bocci\/?p=8205"},"modified":"2022-04-23T14:54:49","modified_gmt":"2022-04-23T05:54:49","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%91state%e3%83%91%e3%82%bf%e3%83%bc%e3%83%b3","status":"publish","type":"post","link":"https:\/\/taki-lab.site\/bocci\/?p=8205","title":{"rendered":"\u3010\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011state\u30d1\u30bf\u30fc\u30f3"},"content":{"rendered":"\n<p>state\u30d1\u30bf\u30fc\u30f3\u306f\u72b6\u614b\u3092\u8868\u3059\u30af\u30e9\u30b9\u3092\u5c0e\u5165\u3059\u308b\u3053\u3068\u306b\u3088\u3063\u3066\u3001\u72b6\u614b\u306b\u5fdc\u3058\u305f\u51e6\u7406\u3092\u5b9f\u884c\u3055\u305b\u308b\u30d1\u30bf\u30fc\u30f3\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u901a\u5e38\u306fif\u6587\u7b49\u3067\u72b6\u614b\u3092\u8868\u3059\u5909\u6570\u3092\u8a55\u4fa1\u3057\u3066\u5224\u65ad\u3057\u307e\u3059\u304c\u3001\u3053\u308c\u3092\u30af\u30e9\u30b9\u306b\u7f6e\u304d\u63db\u3048\u3066\u51e6\u7406\u3059\u308b\u3082\u306e\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>package com.example.state;\r\n\r\nimport java.text.SimpleDateFormat;\r\n\r\npublic interface State {\r\n\tpublic final static SimpleDateFormat sdf = new SimpleDateFormat(\"yyyyMMdd\");\r\n\t\r\n\tpublic void setState(Context context);\r\n\tpublic void methodA();\r\n\tpublic void methodB();\r\n}\r\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>package com.example.state;\r\n\r\npublic class ConcreteState1 implements State {\r\n\tprivate final static State state = new ConcreteState1();\r\n\r\n\tprivate ConcreteState1() {\r\n\t\tsuper();\r\n\t}\r\n\t\r\n\tpublic static State getInstance() {\r\n\t\treturn state;\r\n\t}\r\n\t\r\n\tpublic void setState(Context context) {\r\n\t\tint value = context.getValue();\r\n\t\tif(value == 1) {\r\n\t\t\tcontext.changeState(ConcreteState2.getInstance());\r\n\t\t}\r\n\t}\r\n\r\n\tpublic void methodA() {\r\n\t\t\r\n\t}\r\n\r\n\tpublic void methodB() {\r\n\t\t\r\n\t}\r\n\r\n}\r\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>package com.example.state;\r\n\r\npublic class ConcreteState2 implements State{\r\n\tprivate final static State state = new ConcreteState2();\r\n\t\r\n\tprivate ConcreteState2() {\r\n\t\tsuper();\r\n\t}\r\n\t\r\n\tpublic static State getInstance() {\r\n\t\treturn state;\r\n\t}\r\n\t\r\n\tpublic void setState(Context context) {\r\n\t\tint value = context.getValue();\r\n\t\tif(value == 2) {\r\n\t\t\tcontext.changeState(ConcreteState1.getInstance());\r\n\t\t}\r\n\t}\r\n\r\n\tpublic void methodA() {\r\n\t}\r\n\r\n\tpublic void methodB() {\r\n\t}\r\n}\r\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>package com.example.state;\r\n\r\npublic class Context {\r\n\tprivate int value;\r\n\tprivate State state = ConcreteState2.getInstance();\r\n\t\r\n\tpublic int getValue() {\r\n\t\treturn value;\r\n\t}\r\n\t\r\n\tpublic void setValue(int value) {\r\n\t\tthis.value = value;\r\n\t\tstate.setState(this);\r\n\t}\r\n\t\r\n\tpublic void changeState(State state) {\r\n\t\tthis.state = state;\r\n\t}\r\n\t\r\n\tpublic void methodA() {\r\n\t\tstate.methodA();\r\n\t}\r\n\t\r\n\tpublic void methodB() {\r\n\t\tstate.methodB();\r\n\t}\r\n}\r\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>package com.example.state;\r\n\r\npublic class Main {\r\n\tpublic static void main(String args&#91;]) {\r\n\t\tContext context = new Context();\r\n\t\t\r\n\t\tcontext.setValue(1);\r\n\t\tcontext.methodA();\r\n\t\tcontext.methodB();\r\n\t\tcontext.setValue(2);\r\n\t\tcontext.methodA();\r\n\t\tcontext.methodB();\r\n\t}\r\n\r\n}\r\n<\/code><\/pre>\n\n\n\n<p>\u8a2d\u5b9a\u3057\u305f\u5024\u306b\u5fdc\u3058\u3066context\u306b\u4fdd\u6301\u3059\u308b\u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4fdd\u6301\u3057\u3001<\/p>\n\n\n\n<p>\u305d\u306e\u72b6\u614b\u306b\u5fdc\u3058\u3066\u5b9f\u884c\u3059\u308b\u51e6\u7406\u3092\u3001\u30af\u30e9\u30b9\u306e\u5b9f\u88c5\u3067\u51e6\u7406\u3092\u5909\u66f4\u3055\u305b\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>state\u30d1\u30bf\u30fc\u30f3\u306f\u72b6\u614b\u3092\u8868\u3059\u30af\u30e9\u30b9\u3092\u5c0e\u5165\u3059\u308b\u3053\u3068\u306b\u3088\u3063\u3066\u3001\u72b6\u614b\u306b\u5fdc\u3058\u305f\u51e6\u7406\u3092\u5b9f\u884c\u3055\u305b\u308b\u30d1\u30bf\u30fc\u30f3\u3067\u3059\u3002 \u901a\u5e38\u306fif\u6587\u7b49\u3067\u72b6\u614b\u3092\u8868\u3059\u5909\u6570\u3092\u8a55\u4fa1\u3057\u3066\u5224\u65ad\u3057\u307e\u3059\u304c\u3001\u3053\u308c\u3092\u30af\u30e9\u30b9\u306b\u7f6e\u304d\u63db\u3048\u3066\u51e6\u7406\u3059\u308b\u3082\u306e\u3067\u3059\u3002 \u8a2d\u5b9a\u3057\u305f\u5024\u306b\u5fdc\u3058\u3066 &hellip; <a href=\"https:\/\/taki-lab.site\/bocci\/?p=8205\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">\u3010\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011state\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":"","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":[],"class_list":["post-8205","post","type-post","status-publish","format-standard","hentry","category-225","category-3"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8SDbY-28l","jetpack-related-posts":[{"id":8255,"url":"https:\/\/taki-lab.site\/bocci\/?p=8255","url_meta":{"origin":8205,"position":0},"title":"\u3010\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011Strategy\u30d1\u30bf\u30fc\u30f3","author":"taki","date":"2022\u5e745\u67084\u65e5","format":false,"excerpt":"Strategy\u30d1\u30bf\u30fc\u30f3\u306f\u3042\u308b\u6761\u4ef6\u3092\u304d\u3063\u304b\u3051\u306b\u4e2d\u306e\u51e6\u7406\u3092\u5207\u308a\u66ff\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u30d1\u30bf\u30fc\u30f3\u3067\u3059\u3002 Con\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":4688,"url":"https:\/\/taki-lab.site\/bocci\/?p=4688","url_meta":{"origin":8205,"position":1},"title":"\u3010\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011Adapter\u30d1\u30bf\u30fc\u30f3","author":"taki","date":"2020\u5e7412\u670810\u65e5","format":false,"excerpt":"Adapter\u30d1\u30bf\u30fc\u30f3\u306e\u30b3\u30fc\u30c9\u4f8b\u3067\u3059\u3002 Adapter\u306b\u306f\u7d99\u627f\u3092\u4f7f\u3063\u305f\u30d1\u30bf\u30fc\u30f3\u3068\u59d4\u8b72\u3092\u4f7f\u3063\u305f\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":4535,"url":"https:\/\/taki-lab.site\/bocci\/?p=4535","url_meta":{"origin":8205,"position":2},"title":"\u3010\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011Factory\u30d1\u30bf\u30fc\u30f3","author":"taki","date":"2020\u5e7411\u670811\u65e5","format":false,"excerpt":"\u306a\u3093\u3067\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u306e\u8a71\u306b\u306a\u308b\u3068Java\u306a\u306e\u304b\u306d\uff1f \u307e\u3041\u3001\u6982\u5ff5\u304c\u89e3\u308c\u3070\u4ed6\u306e\u8a00\u8a9e\u306b\u3067\u3082\u5fdc\u7528\u306f\u53ef\u80fd\u3060\u3051\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":4658,"url":"https:\/\/taki-lab.site\/bocci\/?p=4658","url_meta":{"origin":8205,"position":3},"title":"\u3010\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011Singleton\u30d1\u30bf\u30fc\u30f3","author":"taki","date":"2020\u5e7412\u67083\u65e5","format":false,"excerpt":"Singleton\u30d1\u30bf\u30fc\u30f3\u306e\u30b3\u30fc\u30c9\u4f8b\u3067\u3059\u3002 package org.example.singleto\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":8205,"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":4950,"url":"https:\/\/taki-lab.site\/bocci\/?p=4950","url_meta":{"origin":8205,"position":5},"title":"\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011Proxy\u30d1\u30bf\u30fc\u30f3","author":"taki","date":"2021\u5e741\u670821\u65e5","format":false,"excerpt":"Proxy\u30d1\u30bf\u30fc\u30f3\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u3059\u3002 package org.example.proxy; pu\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\/8205","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=8205"}],"version-history":[{"count":1,"href":"https:\/\/taki-lab.site\/bocci\/index.php?rest_route=\/wp\/v2\/posts\/8205\/revisions"}],"predecessor-version":[{"id":8207,"href":"https:\/\/taki-lab.site\/bocci\/index.php?rest_route=\/wp\/v2\/posts\/8205\/revisions\/8207"}],"wp:attachment":[{"href":"https:\/\/taki-lab.site\/bocci\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/taki-lab.site\/bocci\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8205"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/taki-lab.site\/bocci\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}