Home | History | Annotate | Download | only in field
      1 package annotations.field;
      2 
      3 /*>>>
      4 import org.checkerframework.checker.nullness.qual.*;
      5 */
      6 
      7 /**
      8  * A {@link ClassTokenAFT} is the type of an annotation field that holds a
      9  * class token (something like <code>{@link String}.class</code>).
     10  * Even if the field type was originally some parameterization
     11  * <code>{@link Class}&lt;...&gt;</code>, the annotation scene library
     12  * represents it as a plain {@link ClassTokenAFT}.  Use the singleton
     13  * {@link #ctaft}.
     14  */
     15 public final class ClassTokenAFT extends ScalarAFT {
     16 
     17     // On 2006.07.07 we decided against parameterizations because
     18     // class files that use annotations don't contain them.
     19 
     20     // The type arguments, if any, of the field type
     21     // Could be "" or "<HashMap>" (stupid) or "<? extends PrettyPrinter>", etc.,
     22     // but not null.
     23     /* public final String parameterization; */
     24 
     25     private ClassTokenAFT() {}
     26 
     27     /**
     28      * The singleton {@link ClassTokenAFT}.
     29      */
     30     public static final ClassTokenAFT ctaft = new ClassTokenAFT();
     31 
     32     // public ClassTokenAFT(/* String parameterization */) {
     33     //    /* this.parameterization = parameterization; */
     34     // }
     35 
     36     /**
     37      * {@inheritDoc}
     38      */
     39     @Override
     40     public boolean isValidValue(Object o) {
     41         return o instanceof java.lang.Class;
     42     }
     43 
     44     /**
     45      * {@inheritDoc}
     46      */
     47     @Override
     48     public String toString() {
     49         return "Class"/* + parameterization */;
     50     }
     51 
     52     /**
     53      * {@inheritDoc}
     54      */
     55     @Override
     56     public String format(Object o) {
     57         return ((java.lang.Class<?>)o).getName() + ".class";
     58     }
     59 
     60 
     61     @Override
     62     public <R, T> R accept(AFTVisitor<R, T> v, T arg) {
     63         return v.visitClassTokenAFT(this, arg);
     64     }
     65 }
     66