title: Detecting the present annotations within the given object passed into a constructor
body: <p>My question in short: how do I detect if a java annotation is present (and in the right place) for a given user class/object.</p>
  
  <p>Details of the "problem"</p>
  
  <p>Lets say I have two java classes:</p>
  
  <pre><code>public class Line {
     private List&lt;Cell&gt; cells;
  
     public Line(Object... annotatedObjects) {
       // check if annotations @Line and @Cell are present in annotatedObjects.
     }
  
     // getter/setter for cells.
  }
  
  public class Cell {
     // some members
     // some methods
  }
  </code></pre>
  
  <p>A Line object holds Cells.</p>
  
  <p>I also have two annotations, like:</p>
  
  <pre><code>public @interface Line {
    // some stuff here
  }
  
  public @interface Cell {
    // some stuff here
  }
  </code></pre>
  
  <p>I also have a bunch of user classes (two will do for this example) that contain the @Line and @Cell annotations I specified, like:</p>
  
  <pre><code>@Line(name="pqr", schema="three")
  public class AUserClass {
     @Cell
     private String aString;
  }
  
  @Line(name="xyz", schema="four")
  public class AnotherUserClass {
     @Cell(name="birthday")
     private Date aDate;
  }
  </code></pre>
  
  <p>The problem: When I instantiate a new Line object, I want to be able to pass the user classes/objects into the Line constructor. The Line constructor then finds out if the passed user classes/objects are valid classes that can be processed. Only user classes that have a <code>@Line</code> annotation for the class, and at least one <code>@Cell</code> annotation for its members are valid objects that can be passed into the constructor of the Line object.
  All other passed objects are invalid. The moment a valid user object is passed, all the available members that are tagged as <code>@Cell</code> in that object are transformed to Cell objects and added to the cells list.</p>
  
  <p>My questions:</p>
  
  <ol>
  <li>is this possible to detect the annotations in this object/class at runtime, and only for THIS passed object (I don't want to scan for annotations on the classpath!)?</li>
  <li>is it possible to detect the datatype of the <code>@Cell</code> tagged members? This is needed because the Cell class doesn't accept all datatypes.</li>
  <li>is it possible to retrieve the actual member name (specified in the java file) so that the user doesn't have to specify the members Cell name. I want the user to be able to write <code>@Cell</code> (without a name) and <code>@Cell(name="aName")</code>, and when only <code>@Cell</code> is specified, the name of the member is used instead. I have no idea if this information is still available at runtime using reflection.</li>
  <li>How to detect if the annotations are in the right place?If code is tagged like this, then the object should be ignored (or maybe an exception is thrown)?
  <pre><code>@Cell // oh oh, that's no good :(
  public class WrongClass {
  // some members
  }</pre></code></li>
  <li>Could you provide some startup code, so I know a little to get going with this problem. I am really new to annotations and reflection. BTW: I am using the latest jvm 1.6+</li>
  </ol>
  
  <p>Thank you for your kind help!</p>