36 implements GenericArrayType { 37 private final Type genericComponentType; 38 39 // private constructor enforces use of static factory 40 private GenericArrayTypeImpl(Type ct) { 41 genericComponentType = ct; 42 } 43 44 /** 45 * Factory method. 46 * @param ct - the desired component type of the generic array type 47 * being created 48 * @return a generic array type with the desired component type 49 */ 50 public static GenericArrayTypeImpl make(Type ct) { 51 return new GenericArrayTypeImpl(ct); 52 } 53 54 55 /** 56 * Returns a <tt>Type</tt> object representing the component type 57 * of this array. 58 * 59 * @return a <tt>Type</tt> object representing the component type 60 * of this array 61 * @since 1.5 62 */ 63 public Type getGenericComponentType() { 64 return genericComponentType; // return cached component type 65 } 66 67 public String toString() { 68 Type componentType = getGenericComponentType(); 69 StringBuilder sb = new StringBuilder(); 70 71 if (componentType instanceof Class) 72 sb.append(((Class)componentType).getName() ); 73 else 74 sb.append(componentType.toString()); 75 sb.append("[]"); 76 return sb.toString(); 77 } 78 79 @Override | 36 implements GenericArrayType { 37 private final Type genericComponentType; 38 39 // private constructor enforces use of static factory 40 private GenericArrayTypeImpl(Type ct) { 41 genericComponentType = ct; 42 } 43 44 /** 45 * Factory method. 46 * @param ct - the desired component type of the generic array type 47 * being created 48 * @return a generic array type with the desired component type 49 */ 50 public static GenericArrayTypeImpl make(Type ct) { 51 return new GenericArrayTypeImpl(ct); 52 } 53 54 55 /** 56 * Returns a {@code Type} object representing the component type 57 * of this array. 58 * 59 * @return a {@code Type} object representing the component type 60 * of this array 61 * @since 1.5 62 */ 63 public Type getGenericComponentType() { 64 return genericComponentType; // return cached component type 65 } 66 67 public String toString() { 68 Type componentType = getGenericComponentType(); 69 StringBuilder sb = new StringBuilder(); 70 71 if (componentType instanceof Class) 72 sb.append(((Class)componentType).getName() ); 73 else 74 sb.append(componentType.toString()); 75 sb.append("[]"); 76 return sb.toString(); 77 } 78 79 @Override |