61 lowerBounds = lbs; 62 } 63 64 /** 65 * Factory method. 66 * @param ubs - an array of ASTs representing the upper bounds for the type 67 * variable to be created 68 * @param lbs - an array of ASTs representing the lower bounds for the type 69 * variable to be created 70 * @param f - a factory that can be used to manufacture reflective 71 * objects that represent the bounds of this wildcard type 72 * @return a wild card type with the requested bounds and factory 73 */ 74 public static WildcardTypeImpl make(FieldTypeSignature[] ubs, 75 FieldTypeSignature[] lbs, 76 GenericsFactory f) { 77 return new WildcardTypeImpl(ubs, lbs, f); 78 } 79 80 /** 81 * Returns an array of <tt>Type</tt> objects representing the upper 82 * bound(s) of this type variable. Note that if no upper bound is 83 * explicitly declared, the upper bound is <tt>Object</tt>. 84 * 85 * <p>For each upper bound B : 86 * <ul> 87 * <li>if B is a parameterized type or a type variable, it is created, 88 * (see {@link #ParameterizedType} for the details of the creation 89 * process for parameterized types). 90 * <li>Otherwise, B is resolved. 91 * </ul> 92 * 93 * @return an array of Types representing the upper bound(s) of this 94 * type variable 95 * @throws <tt>TypeNotPresentException</tt> if any of the 96 * bounds refers to a non-existent type declaration 97 * @throws <tt>MalformedParameterizedTypeException</tt> if any of the 98 * bounds refer to a parameterized type that cannot be instantiated 99 * for any reason 100 */ 101 public Type[] getUpperBounds() { 102 Object[] value = upperBounds; 103 if (value instanceof FieldTypeSignature[]) { 104 value = reifyBounds((FieldTypeSignature[])value); 105 upperBounds = value; 106 } 107 return (Type[])value.clone(); 108 } 109 110 /** 111 * Returns an array of <tt>Type</tt> objects representing the 112 * lower bound(s) of this type variable. Note that if no lower bound is 113 * explicitly declared, the lower bound is the type of <tt>null</tt>. 114 * In this case, a zero length array is returned. 115 * 116 * <p>For each lower bound B : 117 * <ul> 118 * <li>if B is a parameterized type or a type variable, it is created, 119 * (see {@link #ParameterizedType} for the details of the creation 120 * process for parameterized types). 121 * <li>Otherwise, B is resolved. 122 * </ul> 123 * 124 * @return an array of Types representing the lower bound(s) of this 125 * type variable 126 * @throws <tt>TypeNotPresentException</tt> if any of the 127 * bounds refers to a non-existent type declaration 128 * @throws <tt>MalformedParameterizedTypeException</tt> if any of the 129 * bounds refer to a parameterized type that cannot be instantiated 130 * for any reason 131 */ 132 public Type[] getLowerBounds() { 133 Object[] value = lowerBounds; 134 if (value instanceof FieldTypeSignature[]) { 135 value = reifyBounds((FieldTypeSignature[])value); 136 lowerBounds = value; 137 } 138 return (Type[])value.clone(); 139 } 140 141 public String toString() { 142 Type[] lowerBounds = getLowerBounds(); 143 Type[] bounds = lowerBounds; 144 StringBuilder sb = new StringBuilder(); 145 146 if (lowerBounds.length > 0) 147 sb.append("? super "); 148 else { | 61 lowerBounds = lbs; 62 } 63 64 /** 65 * Factory method. 66 * @param ubs - an array of ASTs representing the upper bounds for the type 67 * variable to be created 68 * @param lbs - an array of ASTs representing the lower bounds for the type 69 * variable to be created 70 * @param f - a factory that can be used to manufacture reflective 71 * objects that represent the bounds of this wildcard type 72 * @return a wild card type with the requested bounds and factory 73 */ 74 public static WildcardTypeImpl make(FieldTypeSignature[] ubs, 75 FieldTypeSignature[] lbs, 76 GenericsFactory f) { 77 return new WildcardTypeImpl(ubs, lbs, f); 78 } 79 80 /** 81 * Returns an array of {@code Type} objects representing the upper 82 * bound(s) of this type variable. Note that if no upper bound is 83 * explicitly declared, the upper bound is {@code Object}. 84 * 85 * <p>For each upper bound B : 86 * <ul> 87 * <li>if B is a parameterized type or a type variable, it is created, 88 * (see {@link #ParameterizedType} for the details of the creation 89 * process for parameterized types). 90 * <li>Otherwise, B is resolved. 91 * </ul> 92 * 93 * @return an array of Types representing the upper bound(s) of this 94 * type variable 95 * @throws {@code TypeNotPresentException} if any of the 96 * bounds refers to a non-existent type declaration 97 * @throws {@code MalformedParameterizedTypeException} if any of the 98 * bounds refer to a parameterized type that cannot be instantiated 99 * for any reason 100 */ 101 public Type[] getUpperBounds() { 102 Object[] value = upperBounds; 103 if (value instanceof FieldTypeSignature[]) { 104 value = reifyBounds((FieldTypeSignature[])value); 105 upperBounds = value; 106 } 107 return (Type[])value.clone(); 108 } 109 110 /** 111 * Returns an array of {@code Type} objects representing the 112 * lower bound(s) of this type variable. Note that if no lower bound is 113 * explicitly declared, the lower bound is the type of {@code null}. 114 * In this case, a zero length array is returned. 115 * 116 * <p>For each lower bound B : 117 * <ul> 118 * <li>if B is a parameterized type or a type variable, it is created, 119 * (see {@link #ParameterizedType} for the details of the creation 120 * process for parameterized types). 121 * <li>Otherwise, B is resolved. 122 * </ul> 123 * 124 * @return an array of Types representing the lower bound(s) of this 125 * type variable 126 * @throws {@code TypeNotPresentException} if any of the 127 * bounds refers to a non-existent type declaration 128 * @throws {@code MalformedParameterizedTypeException} if any of the 129 * bounds refer to a parameterized type that cannot be instantiated 130 * for any reason 131 */ 132 public Type[] getLowerBounds() { 133 Object[] value = lowerBounds; 134 if (value instanceof FieldTypeSignature[]) { 135 value = reifyBounds((FieldTypeSignature[])value); 136 lowerBounds = value; 137 } 138 return (Type[])value.clone(); 139 } 140 141 public String toString() { 142 Type[] lowerBounds = getLowerBounds(); 143 Type[] bounds = lowerBounds; 144 StringBuilder sb = new StringBuilder(); 145 146 if (lowerBounds.length > 0) 147 sb.append("? super "); 148 else { |