{"id":1785,"date":"2013-10-21T15:55:50","date_gmt":"2013-10-21T15:55:50","guid":{"rendered":"http:\/\/salientsoft.co.uk\/?p=1785"},"modified":"2018-10-10T17:15:58","modified_gmt":"2018-10-10T17:15:58","slug":"translating-a-string-enum-value-into-an-enum-given-an-enum-class-object","status":"publish","type":"post","link":"https:\/\/salientsoft.co.uk\/?p=1785","title":{"rendered":"Translating a string Enum value into an Enum given an  Enum class object"},"content":{"rendered":"<p>You can translate a string Enum into its corresponding Enum using the Enum in this way :-<\/p>\n<p>&#160;<\/p>\n<blockquote>\n<p\/>\/\/Assuming Fields is the target Enum<br \/>    String fieldName = \u201cmyField\u201d;<br \/>    Fields field = Fields.valueOf(fieldName); <\/p><\/blockquote>\n<p>&#160;<\/p>\n<p>However this can also be done if you are given a class object of the Enum:-<\/p>\n<p>&#160;<\/p>\n<blockquote>\n<p\/>\/\/Assuming fieldClass is a class object for the Fields Enum<br \/>    String fieldName = \u201cmyField\u201d;<br \/>    Fields field = Enum.valueOf(fieldClass, fieldName);<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>You can translate a string Enum into its corresponding Enum using the Enum in this way :- &#160; \/\/Assuming Fields is the target Enum String fieldName = \u201cmyField\u201d; Fields field = Fields.valueOf(fieldName); &#160; However this can also be done if you are given a class object of the Enum:- &#160; \/\/Assuming fieldClass is a class [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[],"_links":{"self":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1785"}],"collection":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1785"}],"version-history":[{"count":4,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1785\/revisions"}],"predecessor-version":[{"id":2215,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1785\/revisions\/2215"}],"wp:attachment":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1785"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1785"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1785"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}