/** * {@inheritDoc} */ public Generic onTypeVariable(Generic typeVariable) { Generic attachedVariable = typeVariableSource.findVariable(typeVariable.getSymbol()); if (attachedVariable == null) { throw new IllegalArgumentException("Cannot attach undefined variable: " + typeVariable); } else { return new OfTypeVariable.WithAnnotationOverlay(attachedVariable, typeVariable); } }
@Override public boolean equals(Object other) { if (this == other) { return true; } else if (!(other instanceof Generic)) { return false; } Generic typeDescription = (Generic) other; return typeDescription.getSort().isTypeVariable() && getSymbol().equals(typeDescription.getSymbol()) && getTypeVariableSource().equals(typeDescription.getTypeVariableSource()); }
@Override public boolean equals(Object other) { if (this == other) { return true; } else if (!(other instanceof Generic)) { return false; } Generic typeDescription = (Generic) other; return typeDescription.getSort().isTypeVariable() && getSymbol().equals(typeDescription.getSymbol()); }
/** * Append a type parameter * * @param typeParameter Type parameters to append * @param output Output to append to * @param <A> Type of output * @return Supplied output to append to */ public <A extends Appendable> A appendTypeParameter(Generic typeParameter, A output) { try { output.append(typeParameter.getSymbol()); TypeList.Generic upperBounds = typeParameter.getUpperBounds(); if (upperBounds.size() == 0) { throw new IllegalArgumentException( String.format("Type parameter '%s' must have upper bounds", typeParameter)); } if (upperBounds.get(0).isInterface()) { output.append(':'); } for (Generic upperBound : upperBounds) { appendClassOrInterfaceBound(upperBound, output); } return output; } catch (Exception e) { throw new RuntimeException(String.format("Could not write type parameter %s", typeParameter)); } }
String variableSymbol = typeVariable.getSymbol(); if (!typeVariableNames.add(variableSymbol)) { throw new IllegalStateException("Duplicate type variable symbol '" + typeVariable + "' for " + this); String variableSymbol = typeVariable.getSymbol(); if (!methodTypeVariableNames.add(variableSymbol)) { throw new IllegalStateException("Duplicate type variable symbol '" + typeVariable + "' for " + methodDescription);
boolean generic = false; for (TypeDescription.Generic typeVariable : getTypeVariables()) { signatureWriter.visitFormalTypeParameter(typeVariable.getSymbol()); boolean classBound = true; for (TypeDescription.Generic upperBound : typeVariable.getUpperBounds()) {
boolean generic = false; for (Generic typeVariable : getTypeVariables()) { signatureWriter.visitFormalTypeParameter(typeVariable.getSymbol()); for (Generic upperBound : typeVariable.getUpperBounds()) { upperBound.accept(new Generic.Visitor.ForSignatureVisitor(upperBound.asErasure().isInterface()
/** * {@inheritDoc} */ public MethodDefinition.ImplementationDefinition<S> define(MethodDescription methodDescription) { MethodDefinition.ParameterDefinition.Initial<S> initialParameterDefinition = methodDescription.isConstructor() ? defineConstructor(methodDescription.getModifiers()) : defineMethod(methodDescription.getInternalName(), methodDescription.getReturnType(), methodDescription.getModifiers()); ParameterList<?> parameterList = methodDescription.getParameters(); MethodDefinition.ExceptionDefinition<S> exceptionDefinition; if (parameterList.hasExplicitMetaData()) { MethodDefinition.ParameterDefinition<S> parameterDefinition = initialParameterDefinition; for (ParameterDescription parameter : parameterList) { parameterDefinition = parameterDefinition.withParameter(parameter.getType(), parameter.getName(), parameter.getModifiers()); } exceptionDefinition = parameterDefinition; } else { exceptionDefinition = initialParameterDefinition.withParameters(parameterList.asTypeList()); } MethodDefinition.TypeVariableDefinition<S> typeVariableDefinition = exceptionDefinition.throwing(methodDescription.getExceptionTypes()); for (TypeDescription.Generic typeVariable : methodDescription.getTypeVariables()) { typeVariableDefinition = typeVariableDefinition.typeVariable(typeVariable.getSymbol(), typeVariable.getUpperBounds()); } return typeVariableDefinition; }
/** * {@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 String getSymbol() { return typeVariable.getSymbol(); }
/** * {@inheritDoc} */ public SignatureVisitor onTypeVariable(Generic typeVariable) { signatureVisitor.visitTypeVariable(typeVariable.getSymbol()); return signatureVisitor; }
/** * {@inheritDoc} */ public String getSymbol() { return typeVariable.getSymbol(); }
/** * {@inheritDoc} */ public String getSymbol() { return typeVariable.getSymbol(); } }
/** * {@inheritDoc} */ public TypeDescription onTypeVariable(Generic typeVariable) { for (TypeVariableToken typeVariableToken : typeVariableTokens) { if (typeVariable.getSymbol().equals(typeVariableToken.getSymbol())) { return typeVariableToken.getBounds().get(0).accept(this); } } return TargetType.resolve(declaringType.findVariable(typeVariable.getSymbol()).asErasure(), declaringType); }
/** * {@inheritDoc} */ public String getSymbol() { return typeVariable.getSymbol(); }
/** * {@inheritDoc} */ public String getSymbol() { return resolve().getSymbol(); }
/** * Transforms a type variable into a type variable token with its bounds detached. * * @param typeVariable A type variable in its attached state. * @param matcher A matcher that identifies types to detach from the upper bound types. * @return A token representing the detached type variable. */ public static TypeVariableToken of(TypeDescription.Generic typeVariable, ElementMatcher<? super TypeDescription> matcher) { return new TypeVariableToken(typeVariable.getSymbol(), typeVariable.getUpperBounds().accept(new TypeDescription.Generic.Visitor.Substitutor.ForDetachment(matcher)), typeVariable.getDeclaredAnnotations()); }
/** * {@inheritDoc} */ public Generic onTypeVariable(Generic typeVariable) { return new OfTypeVariable.Symbolic(typeVariable.getSymbol(), typeVariable); } }
/** * {@inheritDoc} */ public Generic onTypeVariable(Generic typeVariable) { return new OfTypeVariable.Symbolic(typeVariable.getSymbol(), typeVariable); }
/** * {@inheritDoc} */ public String getSymbol() { return typeVariable.getSymbol(); }