title: How to acces JavaFX fields via Annotation?
body: <p>What I'm trying to do:
  I have a Java program in which I use JavaFX. I created a fxml file in which I created JavaFx controllers, which I then declared in the <strong>AddEmployeeOrderController</strong> class. I would like to transfer these created  controller fields to a POJO. Since I think it is very time-consuming and leads to a lot of careless mistakes, I wanted to automate this process more. My idea was to make an annotation for each declared JavaFX controller field so that, for example, all annotated fields are gonna be retrieved automatically at for example a push of a button in another method. So you can understand it that way instead of writing everything by hand yourself, e.g.:</p>
  <pre><code>EmployeeDto employeeDto = new EmployeeDto(textfield.getText(), textfield2.getText()..);
  </code></pre>
  <p>I first formed the <strong>AddEmployeeOrderController</strong> and declared some JavaFX field and added an annotation. Again in the <strong>AddEmployeeOrderController</strong> class I tried to access the annotated field.</p>
  <p>Then, logically, I would have to cast to cast the java.lang.reflect.Field to a JavaFX TextField, but that is obviously not possible. It throws only IllegalArgumentException errors, and of course because you can't cast a java.lang.reflect.Field to a JavaFX TextField.</p>
  <p>Is there a way in which my idea can be achieved with the help of annotation, or am I forced to write everything by hand and generate so-called boilerplate code.</p>
  <pre><code> public class AddEmployeeOrderController implements Initializale {
       @FXML
       @MyAnno
       public TextField orderDateFromTextField;
  
       public void atPushButton() {
           for (Field field : AddEmployeeOrderController.class.getDeclaredFields()) {
               if (field.isAnnotationPresent(MyAnno.class)) {
                   if (((Field) object).getType().getCanonicalName()
                                                 .contains(&quot;TextField&quot;)) {
                       TextField textField = (TextField) field.get(this);
                       textField.getText();
                   }
               }
           }
       }
   }
  
   @Retention(RetentionPolicy.RUNTIME)
       public @interface MyAnno {
   }
  </code></pre>