{"id":283,"date":"2015-01-24T23:19:25","date_gmt":"2015-01-24T14:19:25","guid":{"rendered":"http:\/\/www.hundredapps.net\/?p=283"},"modified":"2018-04-04T18:46:31","modified_gmt":"2018-04-04T09:46:31","slug":"enum-java%e3%81%ae%e3%81%84%e3%81%be%e3%81%95%e3%82%89%e3%82%b7%e3%83%aa%e3%83%bc%e3%82%ba","status":"publish","type":"post","link":"https:\/\/www.hundredapps.net\/?p=283","title":{"rendered":"Enum Java\u306e\u3044\u307e\u3055\u3089\u30b7\u30ea\u30fc\u30ba"},"content":{"rendered":"<p>enum\u3068\u306f\u3001\u30d7\u30ed\u30b0\u30e9\u30de\u304c\u9078\u3093\u3060\u5404\u3005\u306e\u8b58\u5225\u5b50\u3092\u305d\u306e\u307e\u307e\u6709\u9650\u96c6\u5408\u3068\u3057\u3066\u6301\u3064\u62bd\u8c61\u30c7\u30fc\u30bf\u578b<\/p>\n<p><a href=\"https:\/\/ja.wikipedia.org\/wiki\/%E5%88%97%E6%8C%99%E5%9E%8B\" title=\"enum\" target=\"_blank\">\u53c2\u8003 wikipedia<\/a><\/p>\n<p>enum\u306e\u30e1\u30ea\u30c3\u30c8\u306f\u3001\u30bd\u30fc\u30b9\u306e\u53ef\u8aad\u6027\u304c\u4e0a\u304c\u308a\u3001\u4fdd\u5b88\u6027\u304c\u826f\u304f\u306a\u308b\u70b9\u306b\u3042\u308a\u307e\u3059\u3002<br \/>\n\u307e\u305f\u3001emun\u578b\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306f\u5358\u4e00\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\uff08\u30b7\u30f3\u30b0\u30eb\u30c8\u30f3\uff09\u306b\u306a\u308b\u3002<\/p>\n<pre>\r\npublic class UsecaseDialogStatus {\r\n    public static final int SHOW = 1;\r\n    public static final int POSITIVE = 2;\r\n    public static final int NEGATIVE = 3;\r\n    public static final int CLOSE = 4;\r\n\r\n    public enum DialogStatus {\r\n        SHOW(1),\r\n        POSITIVE(2),\r\n        NEGATIVE(3),\r\n        CLOSE(4);\r\n\r\n        private final int mStatus;\r\n\r\n        DialogStatus(int status) {\r\n            this.mStatus = status;\r\n        }\r\n\r\n        public int getStatus() {\r\n            return mStatus;\r\n        }\r\n    }\r\n\r\n    public static void main(String[] args){\r\n        \/\/ enum\u3058\u3083\u3044\u306a\u3044\u666e\u901a\u306e\u5b9a\u6570\r\n        check(SHOW);\r\n        check(POSITIVE);\r\n        check(8); \/\/ \u5b9a\u7fa9\u3057\u3066\u3044\u306a\u3044\u5024\u3082\u5f15\u6570\u306b\u5165\u308c\u308b\u3053\u3068\u304c\u3067\u304d\u3066\u3057\u307e\u3046\u3002\r\n        check(4); \/\/ \u3053\u306e\u3088\u3046\u306b\u76f4\u63a5\u6570\u5024\u3092\u5165\u308c\u3089\u308c\u308b\u3068\u4fdd\u5b88\u6027\u304c\u60aa\u304f\u306a\u308a\u56f0\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002\r\n\r\n        \/\/ enum\r\n        check(DialogStatus.SHOW);\r\n        check(DialogStatus.POSITIVE);\r\n        check(DialogStatus.NEGATIVE);\r\n        check(DialogStatus.CLOSE);\r\n    }\r\n\r\n    private static void check(int status) {\r\n        switch (status) {\r\n            case SHOW:\r\n                System.out.println(\"This is show. status=\" + status);\r\n                break;\r\n            case POSITIVE:\r\n                System.out.println(\"This is positive. status=\" + status);\r\n                break;\r\n            case NEGATIVE:\r\n                System.out.println(\"This is negative. status=\" + status);\r\n                break;\r\n            case CLOSE:\r\n                System.out.println(\"This is close. status=\" + status);\r\n                break;\r\n        }\r\n    }\r\n\r\n    private static void check(DialogStatus status) {\r\n        switch (status) {\r\n            case SHOW:\r\n                System.out.println(\"This is \" + status.name() + \". status=\" + status.getStatus());\r\n                break;\r\n            case POSITIVE:\r\n                System.out.println(\"This is \" + status.name() + \". status=\" + status.getStatus());\r\n                break;\r\n            case NEGATIVE:\r\n                System.out.println(\"This is \" + status.name() + \". status=\" + status.getStatus());\r\n                break;\r\n            case CLOSE:\r\n                System.out.println(\"This is \" + status.name() + \". status=\" + status.getStatus());\r\n                break;\r\n        }\r\n    }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>enum\u3068\u306f\u3001\u30d7\u30ed\u30b0\u30e9\u30de\u304c\u9078\u3093\u3060\u5404\u3005\u306e\u8b58\u5225\u5b50\u3092\u305d\u306e\u307e\u307e\u6709\u9650\u96c6\u5408\u3068\u3057\u3066\u6301\u3064\u62bd\u8c61\u30c7\u30fc\u30bf\u578b \u53c2\u8003 wikipedia&#8230;<\/p>\n","protected":false},"author":1,"featured_media":293,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,13],"tags":[],"class_list":["post-283","post","type-post","status-publish","format-standard","has-post-thumbnail","category-java","article cf"],"_links":{"self":[{"href":"https:\/\/www.hundredapps.net\/index.php?rest_route=\/wp\/v2\/posts\/283","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hundredapps.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hundredapps.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hundredapps.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hundredapps.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=283"}],"version-history":[{"count":6,"href":"https:\/\/www.hundredapps.net\/index.php?rest_route=\/wp\/v2\/posts\/283\/revisions"}],"predecessor-version":[{"id":408,"href":"https:\/\/www.hundredapps.net\/index.php?rest_route=\/wp\/v2\/posts\/283\/revisions\/408"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hundredapps.net\/index.php?rest_route=\/wp\/v2\/media\/293"}],"wp:attachment":[{"href":"https:\/\/www.hundredapps.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=283"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hundredapps.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=283"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hundredapps.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=283"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}