/** * Creates a signature token that represents the method that is represented by this token. * * @param declaringType The declaring type of the method that this token represents. * @return A signature token representing this token. */ public SignatureToken asSignatureToken(TypeDescription declaringType) { TypeDescription.Generic.Visitor<TypeDescription> visitor = new TypeDescription.Generic.Visitor.Reducing(declaringType, typeVariableTokens); List<TypeDescription> parameters = new ArrayList<TypeDescription>(parameterTokens.size()); for (ParameterDescription.Token parameter : parameterTokens) { parameters.add(parameter.getType().accept(visitor)); } return new SignatureToken(name, returnType.accept(visitor), parameters); }
/** * Creates a new detached key of the given method token. * * @param token The method token to represent as a key. * @return A detached key representing the given method token.. */ protected static Detached of(MethodDescription.SignatureToken token) { return new Detached(token.getName(), token.getParameterTypes().size(), Collections.singleton(token.asTypeToken())); }
@Override public int hashCode() { return 31 * getMethodDescription().asSignatureToken().hashCode() + getTypeDescription().hashCode(); }
/** * Checks if a type declares a method with the same signature as {@code target}. * * @param target The method to be checked. * @param typeDefinition The type to check for declaring a method with the same signature as {@code target}. * @return {@code true} if the supplied type declares a compatible method. */ private boolean matches(MethodDescription target, TypeDefinition typeDefinition) { for (MethodDescription methodDescription : typeDefinition.getDeclaredMethods().filter(isVirtual())) { if (methodDescription.asSignatureToken().equals(target.asSignatureToken())) { if (matcher.matches(typeDefinition.asGenericType())) { return true; } else { break; } } } return false; }
/** * {@inheritDoc} */ public Implementation.SpecialMethodInvocation invokeSuper(MethodDescription.SignatureToken token) { return token.getName().equals(MethodDescription.CONSTRUCTOR_INTERNAL_NAME) ? invokeConstructor(token) : invokeMethod(token); }
/** * {@inheritDoc} */ public SignatureToken asSignatureToken() { return new SignatureToken(getInternalName(), getReturnType().asErasure(), getParameters().asTypeList().asErasures()); }
@Override public boolean equals(Object other) { if (this == other) { return true; } else if (!(other instanceof SpecialMethodInvocation)) { return false; } SpecialMethodInvocation specialMethodInvocation = (SpecialMethodInvocation) other; return getMethodDescription().asSignatureToken().equals(specialMethodInvocation.getMethodDescription().asSignatureToken()) && getTypeDescription().equals(specialMethodInvocation.getTypeDescription()); } }
/** * {@inheritDoc} */ public boolean matches(MethodDescription target) { return target.asSignatureToken().equals(signatureToken); } }
/** * {@inheritDoc} */ public ByteCodeAppender appender(Target implementationTarget) { return new Appender(implementationTarget.invokeSuper(new MethodDescription.SignatureToken(lambdaMethodName, lambdaMethod.getReturnType(), lambdaMethod.getParameterTypes()))); }