{"id":200354,"date":"2013-10-31T14:14:03","date_gmt":"2013-10-31T10:14:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=200354"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=200354","title":{"rendered":"<span class=\"post_title\">Custom Annotation Preprocessor \u2014 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u0430 \u0431\u0430\u0437\u0435 Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0432 IntelliJ IDEA<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442!<\/p>\n<p>  \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u043e \u043c\u043d\u043e\u0439 \u0432\u0441\u0442\u0430\u043b\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0432\u043e\u0438\u0445 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0438 \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. \u041f\u0435\u0440\u0432\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0441\u0435\u0431\u0435 \u0437\u0430\u0434\u0430\u043b\u0430: \u0441 \u0447\u0435\u0433\u043e \u043d\u0430\u0447\u0430\u0442\u044c? \u041f\u043e\u0441\u043b\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u044f \u0440\u0435\u0448\u0438\u043b\u0430 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u0430\u043c\u0438 \u043e\u0442\u0432\u0435\u0442\u043e\u043c \u043d\u0430 \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441. <br \/>  \u0414\u0443\u043c\u0430\u044e, \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0432 java \u0438 \u0441 \u0447\u0435\u043c \u0438\u0445 \u0435\u0434\u044f\u0442, \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u044e\u043d\u043e\u043c\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0443 \u044d\u0442\u043e \u0437\u043d\u0430\u043a\u043e\u043c\u043e ( \u0430 \u043a\u043e\u043c\u0443 \u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u043e, \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0447\u0435\u0441\u0442\u044c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e). \u041a \u0442\u043e\u043c\u0443 \u0436\u0435 \u043d\u0430 \u0445\u0430\u0431\u0440\u0435 \u0435\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f <a href=\"http:\/\/habrahabr.ru\/post\/139736\">\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f<\/a> \u043e\u0431 \u044d\u0442\u043e\u043c \u044f\u0432\u043b\u0435\u043d\u0438\u0438. <br \/>  \u041d\u043e \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u043e \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u0445 \u0432 Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432\u0430\u0448\u0438\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c \u0438 \u043e \u0430\u0432\u0442\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043d\u0430 \u0438\u0445 \u043e\u0441\u043d\u043e\u0432\u0435. \u0410 \u0442\u0430\u043a \u0436\u0435, \u043f\u043e \u0445\u043e\u0434\u0443 \u0434\u0435\u043b\u0430, \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u0432\u0430\u043c, \u043a\u0430\u043a \u0431\u044b\u0441\u0442\u0440\u043e \u0432\u0441\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0432 IDEA (\u0441\u0430\u043c\u0430 \u044f \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0441\u044c \u0432\u0435\u0440\u0441\u0438\u0435\u0439 12.1, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0435\u0441\u0442\u044c \u043e\u0442\u043b\u0438\u0447\u0438\u044f).<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f 2 \u043f\u0440\u043e\u0435\u043a\u0442\u0430: \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u043e\u043f\u0438\u0448\u0435\u043c \u043d\u0430\u0448\u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0438 \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u0438\u0437 \u043d\u0435\u0433\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c jar \u0444\u0430\u0439\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u043a\u043e \u0432\u0442\u043e\u0440\u043e\u043c\u0443 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438.<\/p>\n<h5>\u0428\u0430\u0433 1<\/h5>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 library \u043f\u0440\u043e\u0435\u043a\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0441\u0432\u043e\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e. \u041a\u043b\u0430\u0441\u0441 \u0441 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0435\u0439 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a: <\/p>\n<pre><code class=\"java\">@Target(ElementType.METHOD) @Retention(RetentionPolicy.SOURCE) public @interface CustomAnnotation {      String className();     String value() default &quot;Hello&quot;;     int type() default 0; } <\/code><\/pre>\n<p>  <a href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/lang\/annotation\/RetentionPolicy.html\">@Retention<\/a> \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0430\u0448\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u0438 \u043e\u0442\u0431\u0440\u043e\u0448\u0435\u043d\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u043c (\u0430 \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043c\u044b \u0435\u0451 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c).<\/p>\n<h5>\u0428\u0430\u0433 2<\/h5>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0430\u0448 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439. \u041e\u043d \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043a\u043b\u0430\u0441\u0441, \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u044e\u0449\u0438\u0439 AbstractProcessor. \u0415\u043c\u0443 \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c, \u0447\u0442\u043e \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"java\">@SupportedAnnotationTypes({&quot;*&quot;}) @SupportedSourceVersion(SourceVersion.RELEASE_6) public class CustomProcessor extends AbstractProcessor {  } <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434 process, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043b\u043e\u0433\u0438\u043a\u0443 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u041c\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"java\">@Override     public boolean process(Set&lt;? extends TypeElement&gt; annotations, RoundEnvironment roundEnv) {          for (Element e : roundEnv.getElementsAnnotatedWith(CustomAnnotation.class)) {             CustomAnnotation ca = e.getAnnotation(CustomAnnotation.class);             String name = e.getSimpleName().toString();             char[] c = name.toCharArray();             c[0] = Character.toUpperCase(c[0]);             name = new String(name);             TypeElement clazz = (TypeElement) e.getEnclosingElement();             try {                 JavaFileObject f = processingEnv.getFiler().                         createSourceFile(clazz.getQualifiedName() + &quot;Autogenerate&quot;);                 processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE,                         &quot;Creating &quot; + f.toUri());                 Writer w = f.openWriter();                 try {                     String pack = clazz.getQualifiedName().toString();                     PrintWriter pw = new PrintWriter(w);                     pw.println(&quot;package &quot;                             + pack.substring(0, pack.lastIndexOf('.')) + &quot;;&quot;);                     pw.println(&quot;\\npublic class &quot;                             + clazz.getSimpleName() + &quot;Autogenerate {&quot;);                      TypeMirror type = e.asType();                      pw.println(&quot;\\n    public &quot; + ca.className() + &quot; result = \\&quot;&quot; + ca.value() + &quot;\\&quot;;&quot;);                      pw.println(&quot;    public int type = &quot; + ca.type() + &quot;;&quot;);                       pw.println(&quot;\\n    protected &quot; + clazz.getSimpleName()                             + &quot;Autogenerate() {}&quot;);                     pw.println(&quot;\\n    \/** Handle something. *\/&quot;);                     pw.println(&quot;    protected final void handle&quot; + name                             + &quot;(&quot; + ca.className() + &quot; value&quot; + &quot;) {&quot;);                     pw.println(&quot;\\n\/\/&quot; + e);                     pw.println(&quot;\/\/&quot; + ca);                     pw.println(&quot;\\n        System.out.println(value);&quot;);                     pw.println(&quot;    }&quot;);                     pw.println(&quot;}&quot;);                     pw.flush();                 } finally {                     w.close();                 }             } catch (IOException x) {                 processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,                         x.toString());             }         }         return true;     } <\/code><\/pre>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0444\u0430\u043d\u0442\u0430\u0437\u0438\u044e \u0438 \u043f\u0438\u0441\u0430\u0442\u044c, \u0447\u0442\u043e \u0434\u0443\u0448\u0435 \u0443\u0433\u043e\u0434\u043d\u043e (\u043d\u0443 \u0438\u043b\u0438 \u0447\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f =). \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0432\u044b \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438 \u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u0438 \u043e\u043f\u0438\u0441\u0430\u043b\u0438 \u0432\u0441\u0435 \u0441\u0432\u043e\u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438, \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0443\u0436\u043d\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c jar \u0444\u0430\u0439\u043b. \u0412 Idea 12 \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e: <b>Project Settings -&gt; Artifacts -&gt; Add -&gt; Jar -&gt; From modules\u2026<\/b> \u0414\u0430\u043b\u0435\u0435 \u0434\u0435\u043b\u0430\u0435\u043c <b>Build -&gt; Rebuild Project<\/b> \u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u043d\u0430\u0448 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b jar \u0432 Output \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430. <\/p>\n<h5>\u0428\u0430\u0433 3<\/h5>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438. \u041a \u043f\u0440\u043e\u0435\u043a\u0442\u0443 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 \u043f\u0440\u043e\u0448\u043b\u043e\u043c \u0448\u0430\u0433\u0435 jar \u0444\u0430\u0439\u043b \u0438 \u0440\u0430\u0434\u0443\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u043d\u0430\u0448\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b. \u0412 \u043b\u044e\u0431\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043d\u0430\u0448\u0443 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"java\">public class MyActivity extends Activity {      public void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.main);     }      @CustomAnnotation(className = &quot;String&quot;, type = 1)     public void annotatedMethod(String value) {     } } <\/code><\/pre>\n<p>  \u041f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u043c\u044b \u0443\u043a\u0430\u0437\u0430\u043b\u0438 \u043d\u0430\u0448\u0435\u0439 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 <code>@Target(ElementType.METHOD)<\/code>, \u0430 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0435\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0435\u0434 \u043c\u0435\u0442\u043e\u0434\u043e\u043c.<\/p>\n<h5>\u0428\u0430\u0433 4<\/h5>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043a\u0430\u0436\u0435\u043c Idea \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u0438 \u043c\u0430\u0433\u0438\u044f \u043d\u0430\u0447\u043d\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c! \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0434\u0451\u043c \u0432 <b>Settings<\/b> \u0432 \u0440\u0430\u0437\u0434\u0435\u043b <b>Compiler \u2014 &gt; Annotation Processors<\/b>. \u0421\u0442\u0430\u0432\u0438\u043c \u0433\u0430\u043b\u043e\u0447\u043a\u0443 <b>Enable annotation processing<\/b>, \u0432 \u043f\u043e\u043b\u0435<b> Processor path<\/b> \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043f\u0443\u0442\u044c \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443 jar \u0444\u0430\u0439\u043b\u0443. \u0422\u0430\u043a \u0436\u0435 \u0432 \u043e\u043a\u043d\u0435 <b>Processor FQ name<\/b> \u0432\u0432\u043e\u0434\u0438\u043c \u043f\u043e\u043b\u043d\u043e\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435\u0442 \u044d\u0442\u043e CustomProcessor. \u0417\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u043e\u0435 \u043e\u043a\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/636\/309\/92a\/63630992a2fc007527c8cd31aab8c125.png\"\/><\/p>\n<h5>\u0428\u0430\u0433 5<\/h5>\n<p>  \u0414\u0435\u043b\u0430\u0435\u043c <b>Build -&gt; Rebuild project<\/b> \u0438 \u043d\u0430\u0441\u043b\u0430\u0436\u0434\u0430\u0435\u043c\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438. \u0412 \u0434\u0435\u0440\u0435\u0432\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u043f\u0430\u043f\u043a\u0430 generated, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0443\u0442 \u043b\u0435\u0436\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0444\u0430\u0439\u043b\u044b. <br \/>  \u0412\u043e\u0442 \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0443 \u043c\u0435\u043d\u044f:<\/p>\n<pre><code class=\"java\">public class MyActivityAutogenerate {      public String result = &quot;Hello&quot;;     public int type = 1;      protected MyActivityAutogenerate() {}      \/** Handle something. *\/     protected final void handleannotatedMethod(String value) {  \/\/annotatedMethod(java.lang.String) \/\/@com.example.AnnotationsProcessor.CustomAnnotation(type=1, value=Hello, className=String)          System.out.println(value);     } } <\/code><\/pre>\n<p>  Happy codding!      \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/200354\/\"> http:\/\/habrahabr.ru\/post\/200354\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442!<\/p>\n<p>  \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u043e \u043c\u043d\u043e\u0439 \u0432\u0441\u0442\u0430\u043b\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0432\u043e\u0438\u0445 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0438 \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. \u041f\u0435\u0440\u0432\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0441\u0435\u0431\u0435 \u0437\u0430\u0434\u0430\u043b\u0430: \u0441 \u0447\u0435\u0433\u043e \u043d\u0430\u0447\u0430\u0442\u044c? \u041f\u043e\u0441\u043b\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u044f \u0440\u0435\u0448\u0438\u043b\u0430 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u0430\u043c\u0438 \u043e\u0442\u0432\u0435\u0442\u043e\u043c \u043d\u0430 \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441. <br \/>  \u0414\u0443\u043c\u0430\u044e, \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0432 java \u0438 \u0441 \u0447\u0435\u043c \u0438\u0445 \u0435\u0434\u044f\u0442, \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u044e\u043d\u043e\u043c\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0443 \u044d\u0442\u043e \u0437\u043d\u0430\u043a\u043e\u043c\u043e ( \u0430 \u043a\u043e\u043c\u0443 \u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u043e, \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0447\u0435\u0441\u0442\u044c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e). \u041a \u0442\u043e\u043c\u0443 \u0436\u0435 \u043d\u0430 \u0445\u0430\u0431\u0440\u0435 \u0435\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f <a href=\"http:\/\/habrahabr.ru\/post\/139736\">\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f<\/a> \u043e\u0431 \u044d\u0442\u043e\u043c \u044f\u0432\u043b\u0435\u043d\u0438\u0438. <br \/>  \u041d\u043e \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u043e \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u0445 \u0432 Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432\u0430\u0448\u0438\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c \u0438 \u043e \u0430\u0432\u0442\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043d\u0430 \u0438\u0445 \u043e\u0441\u043d\u043e\u0432\u0435. \u0410 \u0442\u0430\u043a \u0436\u0435, \u043f\u043e \u0445\u043e\u0434\u0443 \u0434\u0435\u043b\u0430, \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u0432\u0430\u043c, \u043a\u0430\u043a \u0431\u044b\u0441\u0442\u0440\u043e \u0432\u0441\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0432 IDEA (\u0441\u0430\u043c\u0430 \u044f \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0441\u044c \u0432\u0435\u0440\u0441\u0438\u0435\u0439 12.1, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0435\u0441\u0442\u044c \u043e\u0442\u043b\u0438\u0447\u0438\u044f).  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-200354","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/200354","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=200354"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/200354\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=200354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=200354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=200354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}