1 package annotations.field;
2 
3 /*>>>
4 import org.checkerframework.checker.nullness.qual.*;
5 */
6 
7 /**
8  * An {@link EnumAFT} is the type of an annotation field that can hold an
9  * constant from a certain enumeration type.
10  */
11 public final class EnumAFT extends ScalarAFT {
12 
13     /**
14      * The name of the enumeration type whose constants the annotation field
15      * can hold.
16      */
17     public final String typeName;
18 
19     /**
20      * Constructs an {@link EnumAFT} for an annotation field that can hold
21      * constants of the enumeration type with the given name.
22      */
23     public EnumAFT(String typeName) {
24         this.typeName = typeName;
25     }
26 
27     /**
28      * {@inheritDoc}
29      */
30     @Override
31     public boolean isValidValue(Object o) {
32         // return o instanceof Enum;
33         return o instanceof String;
34     }
35 
36     /**
37      * {@inheritDoc}
38      */
39     @Override
40     public  String toString() {
41         return "enum " + typeName;
42     }
43 
44     /**
45      * {@inheritDoc}
46      */
47     @Override
48     public String format(Object o) {
49         return typeName + "." + o.toString();
50     }
51 
52 
53     @Override
54     public <R, T> R accept(AFTVisitor<R, T> v, T arg) {
55         return v.visitEnumAFT(this, arg);
56     }
57 }
58