{"id":2674,"date":"2018-05-12T13:19:09","date_gmt":"2018-05-12T04:19:09","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=2674"},"modified":"2023-05-27T20:34:55","modified_gmt":"2023-05-27T11:34:55","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%91gofbuilder%e3%83%91%e3%82%bf%e3%83%bc%e3%83%b3%e3%81%a3%e3%81%a6%e3%81%a9%e3%82%93%e3%81%aa%e3%83%91%e3%82%bf","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=2674","title":{"rendered":"\u3010GoF\u306e\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011\u300cBuilder\u300d\u3063\u3066\u3069\u3093\u306a\u30d1\u30bf\u30fc\u30f3\uff1f"},"content":{"rendered":"<h2>Builder\u30d1\u30bf\u30fc\u30f3\u3063\u3066\u3069\u3093\u306a\u30d1\u30bf\u30fc\u30f3\uff1f<\/h2>\n<p><span style=\"color: #ff0000;\"><strong>\u8907\u96d1\u306a\u624b\u9806\u3067\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u751f\u6210\u3059\u308b\u5834\u5408<\/strong><\/span>\u306b\u4f7f\u3048\u308b\u30d1\u30bf\u30fc\u30f3\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>\u30e1\u30ea\u30c3\u30c8<\/h2>\n<p>\u901a\u5e38\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306e\u521d\u671f\u5316\u51e6\u7406\u3067\u306f\u51fa\u6765\u306a\u3044\u3001<span style=\"color: #ff0000;\"><strong>\u8907\u96d1\u306a\u521d\u671f\u5316\u51e6\u7406<\/strong><\/span>\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001<span style=\"color: #ff0000;\"><strong>\u6570\u591a\u304f\u306e\u521d\u671f\u5316\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u7d44\u307f\u5408\u308f\u305b\u3066\u3001\u5c11\u3057\u6027\u8cea\u306e\u7570\u306a\u308b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u305f\u304f\u3055\u3093\u751f\u6210\u3057\u305f\u3044\u5834\u5408<\/strong><\/span>\u7b49\u306b\u4f7f\u3048\u307e\u3059\u3002<\/p>\n<h3>\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306e\u6570\u304c\u5897\u3084\u305b\u3070\u3044\u3044\u306e\u3067\u306f\uff1f<\/h3>\n<p>\u4f8b\u3048\u3070\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306b\u8272\u3093\u306a\u30b1\u30fc\u30b9\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3092\u5897\u3084\u305b\u3070\u3001\u308f\u3056\u308f\u3056\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u306a\u3093\u3066\u3001\u4f7f\u308f\u306a\u304f\u3066\u3082\u8907\u96d1\u306a\u521d\u671f\u5316\u51e6\u7406\u304c\u3067\u304d\u305d\u3046\u306a\u6c17\u304c\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">public class ConstractaTest {\r\n\r\n\t\/* \u5f15\u65701\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf *\/\r\n\tConstractaTest(String param){\r\n\t}\r\n\t\/* \u5f15\u65702\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf *\/\r\n\tConstractaTest(String param,int param2){\r\n\t}\r\n\t\/* \u5f15\u65705\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf *\/\r\n\tConstractaTest(String param,int param2,int param3,int param4,int param5){\r\n\t}\r\n\r\n}\r\n<\/pre>\n<p>\u3057\u304b\u3057\u3001\u3053\u308c\u3060\u3068\u4e0b\u8a18\u306e\u30c7\u30e1\u30ea\u30c3\u30c8\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u305d\u308c\u3060\u3068\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306e\u6570\u304c\u5897\u3048\u3059\u304e\u308b\u3002<\/li>\n<li>\u958b\u767a\u8005\u304c\u5074\u304c\u3069\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3092\u9078\u3079\u3070\u3088\u3044\u304b\u9078\u5b9a\u304c\u96e3\u3057\u3044\u3002<\/li>\n<li>\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u5f15\u6570\u306e\u6570\u304c\u5897\u6e1b\u3057\u305f\u969b\u306b\u3001\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306e\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u304c\u5927\u5909\u3002<\/li>\n<\/ul>\n<h2>\u3069\u306e\u3088\u3046\u306a\u30af\u30e9\u30b9\u8a2d\u8a08\u304b\uff1f<\/h2>\n<p><span style=\"color: #ff0000;\"><strong>\u3042\u3089\u304b\u3058\u3081\u6b63\u3057\u3044\u751f\u6210\u624b\u9806\u3092\u6c7a\u3081\u305f\u8907\u6570\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u5c02\u7528\u306b\u307e\u3068\u3081\u305f\u30af\u30e9\u30b9<\/strong><\/span>\u547c\u3076\u3053\u3068\u3067\u30011\u3064\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u751f\u6210\u3055\u305b\u307e\u3059\u3002<\/p>\n<p>\u8981\u306f\u3001<span style=\"color: #ff0000;\"><strong>\u300c\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306e\u3088\u3046\u306a\u30af\u30e9\u30b9\u3092\u4f5c\u308b\u300d<\/strong><\/span>\u3068\u3044\u3046\u8868\u73fe\u304c\u4e00\u756a\u7406\u89e3\u306b\u3057\u3063\u304f\u308a\u304f\u308b\u30dd\u30a4\u30f3\u30c8\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<h3>\u5b9f\u88c5\u6642\u6642\u306b\u5fc5\u8981\u306a\u30af\u30e9\u30b9<\/h3>\n<p>\u5b9f\u88c5\u6642\u306f\u3001<strong>\u300c\u30d3\u30eb\u30c0\u30af\u30e9\u30b9\u300d<\/strong>\u3001<strong>\u300c\u30c7\u30a3\u30ec\u30af\u30bf\u30af\u30e9\u30b9\u300d<\/strong>\u306e\u4e8c\u3064\u3092\u5b9f\u88c5\u3059\u308b\u3053\u3068\u304c\u901a\u5e38\u3067\u3059\u3002<\/p>\n<h4>\u30d3\u30eb\u30c0\u30af\u30e9\u30b9<\/h4>\n<p>\u901a\u5e38\u306e\u30af\u30e9\u30b9\u3067\u8a00\u3048\u3070\u3001<span style=\"color: #ff0000;\"><strong>\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3092\u5206\u5272\u3057\u305f\u30e1\u30bd\u30c3\u30c9\u3092\u6301\u3064<\/strong><\/span>\u30af\u30e9\u30b9\u3067\u3059\u3002<\/p>\n<h4>\u30c7\u30a3\u30ec\u30af\u30bf\u30af\u30e9\u30b9<\/h4>\n<p>\u30d3\u30eb\u30c0\u30af\u30e9\u30b9\u306e\u7d20\u6750\u3092\u4f7f\u3063\u3066\u3001<span style=\"color: #ff0000;\"><strong>\u3069\u306e\u3088\u3046\u306a\u624b\u9806\u3067\u521d\u671f\u5316\u3059\u308b\u304b\u3092\u5b9a\u7fa9\u3059\u308b<\/strong><\/span>\u30af\u30e9\u30b9\u3067\u3059\u3002<\/p>\n<h2>\u5b9f\u969b\u306b\u5b9f\u88c5\u3057\u3066\u307f\u308b\u3002<\/h2>\n<p>\u30af\u30e9\u30b9\u56f3\u3067\u6574\u7406\u3059\u308b\u3068\u4e0b\u8a18\u306e\u3088\u3046\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2688\" src=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/05\/\u56f3.png\" alt=\"\" width=\"680\" height=\"603\" srcset=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/05\/\u56f3.png 680w, http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/05\/\u56f3-300x266.png 300w\" sizes=\"(max-width: 680px) 100vw, 680px\" \/><\/p>\n<h3>Main.java(\u30e1\u30a4\u30f3\u30d7\u30ed\u30b0\u30e9\u30e0\uff09<\/h3>\n<pre class=\"lang:default decode:true\">package Builder;\r\n\r\npublic class Main {\r\n\r\n\tpublic static void main(String args[]) {\r\n\r\n\t\tAisatuBuilder aisatuBuild = new AisatuBuilder();\r\n\r\n\t\t\/\/\u4e0b\u304b\u3089\u4e0a\u3078\u306e\u6328\u62f6\r\n\t\tSitaToUe stu = new SitaToUe();\r\n\t\tAisatu aisatu = stu.createAisatu(aisatuBuild);\r\n\t\tSystem.out.println(\"\u4e0b\u304b\u3089\u4e0a\u3078\u306e\u6328\u62f6:\" + aisatu.gendo);\r\n\r\n\t\t\/\/\u4e0a\u304b\u3089\u4e0b\u3078\u306e\u6328\u62f6\r\n\t\tUeToSita uts = new UeToSita();\r\n\t\tAisatu aisatu2 = uts.createAisatu(aisatuBuild);\r\n\t\tSystem.out.println(\"\u4e0a\u304b\u3089\u4e0b\u3078\u306e\u6328\u62f6:\" + aisatu2.gendo);\r\n\r\n\t}\r\n\r\n}\r\n<\/pre>\n<h3>Aisatu.java(\u901a\u5e38\u306e\u30af\u30e9\u30b9\uff1a\u3053\u306e\u30af\u30e9\u30b9\u304c\u6301\u3064\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u8907\u96d1\u306a\u624b\u9806\u3067\u521d\u671f\u5316\u3057\u305f\u3044\uff09<\/h3>\n<pre class=\"lang:default decode:true \">package Builder;\r\n\r\n\/**\r\n * \u6328\u62f6\u306b\u95a2\u3059\u308b\u30af\u30e9\u30b9\r\n *\r\n *\/\r\npublic class Aisatu {\r\n\r\n\t\/* \u6328\u62f6\u306e\u8a00\u52d5 *\/\r\n\tString gendo;\r\n\r\n\tAisatu(String gendo){\r\n\t\tthis.gendo = gendo;\r\n\t}\r\n\r\n}\r\n<\/pre>\n<h3>AisatuBuilder.java(\u30d3\u30eb\u30c0\u30af\u30e9\u30b9\uff1a\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3092\u5206\u5272\u3057\u305f\u30e1\u30bd\u30c3\u30c9\u3092\u591a\u6570\u6301\u3064\u3002\uff09<\/h3>\n<pre class=\"lang:default decode:true \">package Builder;\r\n\r\n\r\n\/**\r\n * \u6328\u62f6\u306e\u8a00\u52d5\u3092\u751f\u6210\u3059\u308b\u30af\u30e9\u30b9\r\n *\/\r\npublic class AisatuBuilder {\r\n\r\n\t\/* \u8a00\u52d5 *\/\r\n\tString gendo;\r\n\r\n\t\/* \u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf *\/\r\n\tAisatuBuilder(){\r\n\t\tthis.gendo = \"\";\r\n\t}\r\n\r\n\t\/* \u4e0a\u304b\u3089\u4e0b\u3078\u306e\u6328\u62f6 *\/\r\n\tvoid ueTositaMessage() {\r\n\t\tgendo += \"\u300c\u304a\u3059\u300d\";\r\n\t}\r\n\r\n\t\/* \u4e0a\u304b\u3089\u4e0b\u3078\u306e\u6328\u62f6 *\/\r\n\tvoid sitaToUeMessage() {\r\n\t\tgendo += \"\u300c\u304a\u306f\u3088\u3046\u3054\u3056\u3044\u307e\u3059\uff01\u300d\";\r\n\t}\r\n\r\n\t\/* \u4e0a\u304b\u3089\u4e0b\u3078\u306e\u6328\u62f6\u306e\u614b\u5ea6 *\/\r\n\tvoid ueTositaTaido() {\r\n\t\tgendo += \"\u3068\u76ee\u3092\u898b\u305a\u306b\u3059\u308b\u3002\";\r\n\t}\r\n\r\n\t\/* \u4e0a\u304b\u3089\u4e0b\u3078\u306e\u6328\u62f6 *\/\r\n\tvoid sitaToUeTaido() {\r\n\t\tgendo += \"\u3068\u76ee\u3092\u898b\u3066\u5143\u6c17\u826f\u304f\u3059\u308b\u3002\";\r\n\t}\r\n\r\n\tAisatu getAisatu() {\r\n\t\tAisatu aisatuBuildResult = new Aisatu(gendo);\r\n\t\tgendo = \"\";\r\n\t\treturn aisatuBuildResult;\r\n\t}\r\n\r\n}\r\n<\/pre>\n<h3>SitaToUe.java(\u30c7\u30a3\u30ec\u30af\u30bf\u30af\u30e9\u30b9\uff11\uff1a\u521d\u671f\u5316\u624b\u9806\u3092\u6301\u3064\uff09<\/h3>\n<pre class=\"lang:default decode:true \">package Builder;\r\n\r\npublic class SitaToUe {\r\n\r\n\tAisatu createAisatu(AisatuBuilder build) {\r\n\t\tbuild.sitaToUeMessage();\r\n\t\tbuild.sitaToUeTaido();\r\n\t\treturn build.getAisatu();\r\n\t}\r\n\r\n}\r\n<\/pre>\n<h3>UeToSita.java(\u30c7\u30a3\u30ec\u30af\u30bf\u30af\u30e9\u30b92\uff1a\u521d\u671f\u5316\u624b\u9806\u3092\u6301\u3064\uff09<\/h3>\n<pre class=\"lang:default decode:true\">package Builder;\r\n\r\npublic class UeToSita {\r\n\tAisatu createAisatu(AisatuBuilder build) {\r\n\t\tbuild.ueTositaMessage();\r\n\t\tbuild.ueTositaTaido();\r\n\t\treturn build.getAisatu();\r\n\t}\r\n}<\/pre>\n<h3>\u00a0\u5b9f\u884c\u7d50\u679c<\/h3>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2689\" src=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/05\/Builder_\u5b9f\u884c\u7d50\u679c.png\" alt=\"\" width=\"417\" height=\"111\" srcset=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/05\/Builder_\u5b9f\u884c\u7d50\u679c.png 417w, http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/05\/Builder_\u5b9f\u884c\u7d50\u679c-300x80.png 300w\" sizes=\"(max-width: 417px) 100vw, 417px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"Builder\u30d1\u30bf\u30fc\u30f3\u3063\u3066\u3069\u3093\u306a\u30d1\u30bf\u30fc\u30f3\uff1f \u8907\u96d1\u306a\u624b\u9806\u3067\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u751f\u6210\u3059\u308b\u5834\u5408\u306b\u4f7f\u3048\u308b\u30d1\u30bf\u30fc\u30f3\u306b\u306a\u308a\u307e\u3059\u3002 \u30e1\u30ea\u30c3\u30c8 \u901a\u5e38\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306e\u521d\u671f\u5316\u51e6\u7406\u3067\u306f\u51fa\u6765\u306a\u3044\u3001\u8907\u96d1\u306a\u521d\u671f\u5316\u51e6\u7406\u304c\u3067\u304d\u307e\u3059\u3002 \u4f8b\u3048\u3070\u3001\u6570\u591a\u304f\u306e\u521d\u671f\u5316 [&hellip;]","protected":false},"author":1,"featured_media":2688,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,21],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/2674"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2674"}],"version-history":[{"count":14,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/2674\/revisions"}],"predecessor-version":[{"id":20228,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/2674\/revisions\/20228"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/media\/2688"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2674"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2674"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2674"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}