{"id":4936,"date":"2014-03-30T17:09:11","date_gmt":"2014-03-30T17:09:11","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/java-annotation-execute-a-method-within-the-annotation-declarationusage-for-android-collection-of-common-programming-errors\/"},"modified":"2014-03-30T17:09:11","modified_gmt":"2014-03-30T17:09:11","slug":"java-annotation-execute-a-method-within-the-annotation-declarationusage-for-android-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/java-annotation-execute-a-method-within-the-annotation-declarationusage-for-android-collection-of-common-programming-errors\/","title":{"rendered":"Java annotation execute a method within the annotation declaration(usage for android)-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m fairly new to the annotation terms. I have read some sources and came to the conclusion that non answered my question. Perhaps I googled using the wrong search. Perhaps I overlook, or mayhbe im just clueless..<\/p>\n<p>Anyway here is the deal.<\/p>\n<p>I am busy writing an application that requires &#8220;role validation&#8221;.<\/p>\n<p>To do this I want to use an annotation.<\/p>\n<p>So something along the line of:<\/p>\n<pre><code>@interface Validate (){\n\n}\n<\/code><\/pre>\n<p>What I aim to achieve is sometihng along the lines of:<\/p>\n<pre><code>public @interface Validate() {\n   public Validate() {\n      \/\/Do validation stuff\n     return true\/false\n   }\n}\n<\/code><\/pre>\n<p>So basically I want to define methods within the annotation. I want to be able to call<\/p>\n<pre><code>@Validate\npublic void methodThatRequiresAdminRole() {\n  doStuff();\n}\n<\/code><\/pre>\n<p>Only admins should be able to enter this method. Otherwise an error should be generated.<\/p>\n<p>so if @validate returns true, the method should be executed<\/p>\n<p>Sorry if I am really unclear. I am not quite sure how to properly ask what I want. So I hope the examples tell the stories.<\/p>\n<p>Hope to read tips and perhaps even an answer soon. Thanks.<\/p>\n<p>** EDIT **<\/p>\n<p>I need to stress out the fact that the code must be used on an android application. So I prefer to not use strange frameworks not meant for android. I have no problem adding a custom library that gives the functionality without any kind of application framework.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m fairly new to the annotation terms. I have read some sources and came to the conclusion that non answered my question. Perhaps I googled using the wrong search. Perhaps I overlook, or mayhbe im just clueless.. Anyway here is the deal. I am busy writing an application that requires &#8220;role validation&#8221;. To do this [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4936","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4936","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4936"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4936\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4936"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4936"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4936"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}