@Override public String toString() { StringBuilder stringBuilder = new StringBuilder(SYMBOL); TypeList.Generic bounds = getLowerBounds(); if (!bounds.isEmpty()) { stringBuilder.append(" super "); } else { bounds = getUpperBounds(); if (bounds.getOnly().equals(TypeDescription.Generic.OBJECT)) { return SYMBOL; } stringBuilder.append(" extends "); } return stringBuilder.append(bounds.getOnly().getTypeName()).toString(); }
/** * {@inheritDoc} */ public TypeDescription.Generic onTypeVariable(TypeDescription.Generic typeVariable) { TypeList.Generic candidates = getTypeVariables().filter(named(typeVariable.getSymbol())); TypeDescription.Generic attached = candidates.isEmpty() ? instrumentedType.findVariable(typeVariable.getSymbol()) : candidates.getOnly(); if (attached == null) { throw new IllegalArgumentException("Cannot attach undefined variable: " + typeVariable); } else { return new TypeDescription.Generic.OfTypeVariable.WithAnnotationOverlay(attached, typeVariable); } } }
/** * {@inheritDoc} */ public SignatureVisitor onWildcard(Generic wildcard) { TypeList.Generic upperBounds = wildcard.getUpperBounds(), lowerBounds = wildcard.getLowerBounds(); if (lowerBounds.isEmpty() && upperBounds.getOnly().represents(Object.class)) { signatureVisitor.visitTypeArgument(); } else if (!lowerBounds.isEmpty() /* && upperBounds.isEmpty() */) { lowerBounds.getOnly().accept(new ForSignatureVisitor(signatureVisitor.visitTypeArgument(SignatureVisitor.SUPER))); } else /* if (!upperBounds.isEmpty() && lowerBounds.isEmpty()) */ { upperBounds.getOnly().accept(new ForSignatureVisitor(signatureVisitor.visitTypeArgument(SignatureVisitor.EXTENDS))); } return signatureVisitor; }
/** * {@inheritDoc} */ public TypeDescription.Generic findVariable(String symbol) { TypeList.Generic typeVariables = getTypeVariables().filter(named(symbol)); if (typeVariables.isEmpty()) { TypeVariableSource enclosingSource = getEnclosingSource(); return enclosingSource == null ? TypeDescription.Generic.UNDEFINED : enclosingSource.findVariable(symbol); } else { return typeVariables.getOnly(); } } }
/** * {@inheritDoc} */ public boolean isAssignableFrom(Generic typeDescription) { if (typeDescription.getSort().isWildcard()) { TypeList.Generic lowerBounds = typeDescription.getLowerBounds(); return !lowerBounds.isEmpty() && lowerBounds.getOnly().accept(Assigner.INSTANCE).isAssignableFrom(lowerBound); } else { return typeDescription.getSort().isWildcard() || typeDescription.accept(Assigner.INSTANCE).isAssignableFrom(lowerBound); } } }
/** * {@inheritDoc} */ public Boolean onWildcard(Generic wildcard) { if (!isValid(wildcard)) { return false; } TypeList.Generic lowerBounds = wildcard.getLowerBounds(); return (lowerBounds.isEmpty() ? wildcard.getUpperBounds() : lowerBounds).getOnly().accept(this); }
/** * {@inheritDoc} */ public boolean isAssignableFrom(Generic typeDescription) { if (typeDescription.getSort().isWildcard()) { return typeDescription.getLowerBounds().isEmpty() && upperBound.accept(Assigner.INSTANCE) .isAssignableFrom(typeDescription.getUpperBounds().getOnly()); } else { return upperBound.accept(Assigner.INSTANCE).isAssignableFrom(typeDescription); } } }
/** * {@inheritDoc} */ public AnnotationAppender onWildcard(TypeDescription.Generic wildcard) { TypeList.Generic lowerBounds = wildcard.getLowerBounds(); return (lowerBounds.isEmpty() ? wildcard.getUpperBounds().getOnly() : lowerBounds.getOnly()).accept(new ForTypeAnnotations(apply(wildcard, typePath), annotationValueFilter, typeReference, typePath + WILDCARD_TYPE_PATH)); }