/** * {@inheritDoc} */ public boolean matches(T target) { return matcher.matches(target.asTypeList()); }
/** * {@inheritDoc} */ public String apply(TypeDescription instrumentedType, MethodDescription instrumentedMethod) { StringBuilder stringBuilder = new StringBuilder("("); boolean comma = false; for (TypeDescription typeDescription : instrumentedMethod.getParameters().asTypeList().asErasures()) { if (comma) { stringBuilder.append(','); } else { comma = true; } stringBuilder.append(typeDescription.getName()); } return stringBuilder.append(')').toString(); } }
/** * {@inheritDoc} */ public String getDescriptor() { StringBuilder descriptor = new StringBuilder().append('('); for (TypeDescription parameterType : getParameters().asTypeList().asErasures()) { descriptor.append(parameterType.getDescriptor()); } return descriptor.append(')').append(getReturnType().asErasure().getDescriptor()).toString(); }
/** * Extracts all parameters of a method to fields. * * @param methodDescription The method to extract the parameters from. * @return A linked hash map of field names to the types of these fields representing all parameters of the * given method. */ private static LinkedHashMap<String, TypeDescription> extractFields(MethodDescription methodDescription) { TypeList parameterTypes = methodDescription.getParameters().asTypeList().asErasures(); LinkedHashMap<String, TypeDescription> typeDescriptions = new LinkedHashMap<String, TypeDescription>(); int currentIndex = 0; for (TypeDescription parameterType : parameterTypes) { typeDescriptions.put(fieldName(currentIndex++), parameterType); } return typeDescriptions; }
@Override public int hashCode() { int hashCode = 17 + getDeclaringType().hashCode(); hashCode = 31 * hashCode + getInternalName().hashCode(); hashCode = 31 * hashCode + getReturnType().asErasure().hashCode(); return 31 * hashCode + getParameters().asTypeList().asErasures().hashCode(); }
/** * {@inheritDoc} */ public ParameterList<ParameterDescription.InDefinedShape> getParameters() { return new ParameterList.Explicit.ForTypes(this, methodDescription.getParameters().asTypeList().asRawTypes()); }
/** * {@inheritDoc} */ public int getStackSize() { return getParameters().asTypeList().getStackSize() + (isStatic() ? 0 : 1); }
/** * {@inheritDoc} */ public ParameterList<ParameterDescription.InDefinedShape> getParameters() { return new ParameterList.Explicit.ForTypes(this, methodDescription.getParameters().asTypeList().asRawTypes()); }
/** * {@inheritDoc} */ public ParameterList<ParameterDescription.InDefinedShape> getParameters() { return new ParameterList.Explicit.ForTypes(this, bridgeTarget.getParameters().asTypeList().asRawTypes()); }
@Override public boolean equals(Object other) { if (this == other) { return true; } else if (!(other instanceof MethodDescription)) { return false; } MethodDescription methodDescription = (MethodDescription) other; return getInternalName().equals(methodDescription.getInternalName()) && getDeclaringType().equals(methodDescription.getDeclaringType()) && getReturnType().asErasure().equals(methodDescription.getReturnType().asErasure()) && getParameters().asTypeList().asErasures().equals(methodDescription.getParameters().asTypeList().asErasures()); }
/** * {@inheritDoc} */ public ParameterList<ParameterDescription.InDefinedShape> getParameters() { return new ParameterList.Explicit.ForTypes(this, CompoundList.of(methodDescription.getParameters().asTypeList().asErasures(), placeholderType)); }
/** * {@inheritDoc} */ public Resolved resolve(TypeDescription instrumentedType, MethodDescription instrumentedMethod, Assigner assigner, Assigner.Typing typing) { return new Resolved.Simple(MethodVariableAccess.allArgumentsOf(instrumentedMethod), instrumentedMethod.getParameters().asTypeList().asErasures()); }
/** * Returns a method type description of the given method. * * @param methodDescription The method to extract the method type from. * @return The method type of the given method. */ public static MethodType of(MethodDescription methodDescription) { return new MethodType(methodDescription.getReturnType().asErasure(), methodDescription.getParameters().asTypeList().asErasures()); }
/** * {@inheritDoc} */ public TypeToken asTypeToken() { return new TypeToken(getReturnType().asErasure(), getParameters().asTypeList().asErasures()); }
/** * {@inheritDoc} */ public Resolved resolve(TypeDescription instrumentedType, MethodDescription instrumentedMethod, Assigner assigner, Assigner.Typing typing) { return new Resolved.Simple(MethodVariableAccess.allArgumentsOf(instrumentedMethod).prependThisReference(), instrumentedMethod.isStatic() ? instrumentedMethod.getParameters().asTypeList().asErasures() : CompoundList.of(instrumentedMethod.getDeclaringType().asErasure(), instrumentedMethod.getParameters().asTypeList().asErasures())); }
@Override protected int copy(TypeDescription instrumentedType, MethodDescription instrumentedMethod, MethodDescription methodDescription, Object[] localVariable, Object[] translated) { int index = 0; if (!instrumentedMethod.isStatic()) { translated[index++] = toFrame(instrumentedType); } for (TypeDescription typeDescription : instrumentedMethod.getParameters().asTypeList().asErasures()) { translated[index++] = toFrame(typeDescription); } return index; }
/** * {@inheritDoc} */ public SignatureToken asSignatureToken() { return new SignatureToken(getInternalName(), getReturnType().asErasure(), getParameters().asTypeList().asErasures()); }
/** * Creates a method handle representation of the given method. * * @param methodDescription The method ro represent. * @return A method handle representing the given method. */ public static MethodHandle of(MethodDescription.InDefinedShape methodDescription) { return new MethodHandle(HandleType.of(methodDescription), methodDescription.getDeclaringType().asErasure(), methodDescription.getInternalName(), methodDescription.getReturnType().asErasure(), methodDescription.getParameters().asTypeList().asErasures()); }
/** * {@inheritDoc} */ public int getOffset() { TypeList parameterType = getDeclaringMethod().getParameters().asTypeList().asErasures(); int offset = getDeclaringMethod().isStatic() ? StackSize.ZERO.getSize() : StackSize.SINGLE.getSize(); for (int i = 0; i < getIndex(); i++) { offset += parameterType.get(i).getStackSize().getSize(); } return offset; }
/** * {@inheritDoc} */ public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext) { return new Compound( ClassConstant.of(methodDescription.getDeclaringType()), methodName(), ArrayFactory.forType(TypeDescription.Generic.OfNonGenericType.CLASS) .withValues(typeConstantsFor(methodDescription.getParameters().asTypeList().asErasures())), MethodInvocation.invoke(accessorMethod()) ).apply(methodVisitor, implementationContext); }