42 public class FieldRepository extends AbstractRepository<TypeSignature> { 43 44 /** The generic type info. Lazily initialized. */ 45 private volatile Type genericType; 46 47 // protected, to enforce use of static factory yet allow subclassing 48 protected FieldRepository(String rawSig, GenericsFactory f) { 49 super(rawSig, f); 50 } 51 52 protected TypeSignature parse(String s) { 53 return SignatureParser.make().parseTypeSig(s); 54 } 55 56 /** 57 * Static factory method. 58 * @param rawSig - the generic signature of the reflective object 59 * that this repository is servicing 60 * @param f - a factory that will provide instances of reflective 61 * objects when this repository converts its AST 62 * @return a <tt>FieldRepository</tt> that manages the generic type 63 * information represented in the signature <tt>rawSig</tt> 64 */ 65 public static FieldRepository make(String rawSig, GenericsFactory f) { 66 return new FieldRepository(rawSig, f); 67 } 68 69 /* 70 * When queried for a particular piece of type information, the 71 * general pattern is to consult the corresponding cached value. 72 * If the corresponding field is non-null, it is returned. 73 * If not, it is created lazily. This is done by selecting the appropriate 74 * part of the tree and transforming it into a reflective object 75 * using a visitor, which is created by feeding it the factory 76 * with which the repository was created. 77 */ 78 79 public Type getGenericType() { 80 Type value = genericType; 81 if (value == null) { 82 value = computeGenericType(); 83 genericType = value; | 42 public class FieldRepository extends AbstractRepository<TypeSignature> { 43 44 /** The generic type info. Lazily initialized. */ 45 private volatile Type genericType; 46 47 // protected, to enforce use of static factory yet allow subclassing 48 protected FieldRepository(String rawSig, GenericsFactory f) { 49 super(rawSig, f); 50 } 51 52 protected TypeSignature parse(String s) { 53 return SignatureParser.make().parseTypeSig(s); 54 } 55 56 /** 57 * Static factory method. 58 * @param rawSig - the generic signature of the reflective object 59 * that this repository is servicing 60 * @param f - a factory that will provide instances of reflective 61 * objects when this repository converts its AST 62 * @return a {@code FieldRepository} that manages the generic type 63 * information represented in the signature {@code rawSig} 64 */ 65 public static FieldRepository make(String rawSig, GenericsFactory f) { 66 return new FieldRepository(rawSig, f); 67 } 68 69 /* 70 * When queried for a particular piece of type information, the 71 * general pattern is to consult the corresponding cached value. 72 * If the corresponding field is non-null, it is returned. 73 * If not, it is created lazily. This is done by selecting the appropriate 74 * part of the tree and transforming it into a reflective object 75 * using a visitor, which is created by feeding it the factory 76 * with which the repository was created. 77 */ 78 79 public Type getGenericType() { 80 Type value = genericType; 81 if (value == null) { 82 value = computeGenericType(); 83 genericType = value; |