/** * Creates a wildcard reference to {@link Object} or returns a wildcard to an {@link UnknownTypeReference} if no * JRE is available. */ @Override public WildcardTypeReference newWildcardExtendsObject() { WildcardTypeReference result = newWildcardTypeReference(); result.addUpperBound(newReferenceToObject()); return result; }
/** * Creates a new wildcard type reference with the given type as the upper bound. * For example: * <pre>wildcardExtends(typeRef(CharSequence))</pre> * would create a type reference representing * <pre>? extends CharSequence</pre> * * @param extendsBound * the upper bound of the wildcard * @return the newly created wildcard type reference */ public JvmTypeReference wildcardExtends(JvmTypeReference extendsBound) { WildcardTypeReference wildcardTypeReference = typeReferenceOwner.newWildcardTypeReference(); wildcardTypeReference.addUpperBound(typeReferenceOwner.toLightweightTypeReference(extendsBound)); return wildcardTypeReference.toTypeReference(); }
/** * Creates a new wildcard type reference with the given type as the lower bound and {@link Object} as upper bound. * * For example: * <pre>wildcardSuper(typeRef(CharSequence))</pre> * would create a type reference representing * <pre>? super CharSequence</pre> * * @param superBound * the super bound of the wildcard * @return the newly created wildcard type reference */ public JvmTypeReference wildcardSuper(JvmTypeReference superBound) { WildcardTypeReference wildcardTypeReference = typeReferenceOwner.newWildcardTypeReference(); wildcardTypeReference.addUpperBound(typeReferenceOwner.toLightweightTypeReference(typeRef(Object.class))); wildcardTypeReference.setLowerBound(typeReferenceOwner.toLightweightTypeReference(superBound)); return wildcardTypeReference.toTypeReference(); }