title: Access to class attributes' values using Java Annotations
body: <p>I am working with a java example using annotations, I created a simple POJO (java bean) using annotations to its attributes. I want to have the ability to create new objects of this type and retrieve the values of its attributes using the annotations created.</p>
  
  <p>My POJO :</p>
  
  <pre><code>import java.io.Serializable;
  
  import annotations.BusinessObject;
  import annotations.BusinessObjectAttribute;
  import annotations.BusinessObjectName;
  import annotations.BusinessObjectPolicy;
  import annotations.BusinessObjectRevision;
  import annotations.BusinessObjectVault;
  
  @BusinessObject
  public class IndusTask implements Serializable{
  
  /**
   * 
   */
  private static final long serialVersionUID = 1L;
  
  
  // Mandatory to create new object !
  @BusinessObjectName
  private String taskName;
  @BusinessObjectRevision
  private String taskRevision;
  @BusinessObjectVault
  private String vault;
  // Mandatory to invoke iTask.create(context, policy) in Database
  @BusinessObjectPolicy
  private String policy;
  
  //Specific attributes
  @BusinessObjectAttribute
  private String taskDescription;
  @BusinessObjectAttribute
  private String creationDate;
  @BusinessObjectAttribute
  private Integer weight;
  
  public IndusTask() {
  }
  
  public IndusTask(String taskName, String taskRevision, String vault, String policy, String taskDescription,
          String creationDate, Integer weight) {
      super();
      this.taskName = taskName;
      this.taskRevision = taskRevision;
      this.vault = vault;
      this.policy = policy;
      this.taskDescription = taskDescription;
      this.creationDate = creationDate;
      this.weight = weight;
  }
  
  public String getTaskName() {
      return taskName;
  }
  
  public void setTaskName(String taskName) {
      this.taskName = taskName;
  }
  
  public String getTaskRevision() {
      return taskRevision;
  }
  
  public void setTaskRevision(String taskRevision) {
      this.taskRevision = taskRevision;
  }
  
  public String getVault() {
      return vault;
  }
  
  public void setVault(String vault) {
      this.vault = vault;
  }
  
  public String getTaskDescription() {
      return taskDescription;
  }
  
  public void setTaskDescription(String taskDescription) {
      this.taskDescription = taskDescription;
  }
  
  public String getCreationDate() {
      return this.creationDate;
  }
  
  public void setCreationDate(String creationDate) {
      this.creationDate = creationDate;
  }
  
  public Integer getWeight() {
      return weight;
  }
  
  public void setWeight(Integer weight) {
      this.weight = weight;
  }
  
  public String getPolicy() {
      return policy;
  }
  
  public void setPolicy(String policy) {
      this.policy = policy;
  }
  
  }
  </code></pre>
  
  <p>Example of attributes' declaration:
  *Business Object Type declaration</p>
  
  <pre><code>package annotations;
  
  import java.lang.annotation.*;
  
  //@Target(ElementType.TYPE)
  @Retention(RetentionPolicy.RUNTIME)
  public @interface BusinessObject {
  
  }
  </code></pre>
  
  <p>*Business Object Name Attribute:</p>
  
  <pre><code>package annotations;
  
  import java.lang.annotation.*;
  
  //@Target(ElementType.FIELD)
  @Retention(RetentionPolicy.RUNTIME)
  public @interface BusinessObjectName {
  
  }
  </code></pre>
  
  <p>I Created a main to test if all the annotations are detected:</p>
  
  <pre><code>public class MainImpl {
  
      public static void main(String[] args) {
          // TODO Auto-generated method stub
  
  
          IndusTask myTask = new IndusTask("mytstTask", "001", "eService Production", "TstTask Process",
                  "myTstTask Description", "2018/02/16@15:30:10:GMT", 200);
  
          System.out.println(myTask.getClass().getAnnotations().length);
  
      }
  
  }
  </code></pre>
  
  <p>Output is displaying 1 ! so only the first annotation is detected !</p>
  
  <p>I was told also that the object attributes values can be accessed using these annotation (something similar to) :</p>
  
  <pre><code>object.getClass().getAnnotations()
  </code></pre>
  
  <p>How can i do ? </p>