/** * {@inheritDoc} */ public int getActualModifiers(boolean manifest, Visibility visibility) { return ModifierContributor.Resolver.of(Collections.singleton(getVisibility().expandTo(visibility))).resolve(getActualModifiers(manifest)); }
int modifiers = getModifiers() & SOURCE_MODIFIERS; if (modifiers != EMPTY_MASK) { stringBuilder.append(Modifier.toString(modifiers)).append(' '); if (isMethod()) { stringBuilder.append(getReturnType().getActualName()).append(' '); stringBuilder.append(getDeclaringType().asErasure().getActualName()).append('.'); stringBuilder.append(getName()).append('('); boolean first = true; for (TypeDescription.Generic typeDescription : getParameters().asTypeList()) { if (!first) { stringBuilder.append(','); TypeList.Generic exceptionTypes = getExceptionTypes(); if (!exceptionTypes.isEmpty()) { stringBuilder.append(" throws ");
/** * {@inheritDoc} */ public <T> T getDefaultValue(Class<T> type) { return type.cast(getDefaultValue()); }
SignatureWriter signatureWriter = new SignatureWriter(); boolean generic = false; for (TypeDescription.Generic typeVariable : getTypeVariables()) { signatureWriter.visitFormalTypeParameter(typeVariable.getSymbol()); boolean classBound = true; for (TypeDescription.Generic parameterType : getParameters().asTypeList()) { parameterType.accept(new TypeDescription.Generic.Visitor.ForSignatureVisitor(signatureWriter.visitParameterType())); generic = generic || !parameterType.getSort().isNonGeneric(); TypeDescription.Generic returnType = getReturnType(); returnType.accept(new TypeDescription.Generic.Visitor.ForSignatureVisitor(signatureWriter.visitReturnType())); generic = generic || !returnType.getSort().isNonGeneric(); TypeList.Generic exceptionTypes = getExceptionTypes(); if (!exceptionTypes.filter(not(ofSort(TypeDefinition.Sort.NON_GENERIC))).isEmpty()) { for (TypeDescription.Generic exceptionType : exceptionTypes) {
@Override public String toString() { StringBuilder stringBuilder = new StringBuilder(); int modifiers = getModifiers() & SOURCE_MODIFIERS; if (modifiers != EMPTY_MASK) { stringBuilder.append(Modifier.toString(modifiers)).append(' '); if (isMethod()) { stringBuilder.append(getReturnType().asErasure().getActualName()).append(' '); stringBuilder.append(getDeclaringType().asErasure().getActualName()).append('.'); stringBuilder.append(getName()).append('('); boolean first = true; for (TypeDescription typeDescription : getParameters().asTypeList().asErasures()) { if (!first) { stringBuilder.append(','); TypeList exceptionTypes = getExceptionTypes().asErasures(); if (!exceptionTypes.isEmpty()) { stringBuilder.append(" throws ");
/** * {@inheritDoc} */ public MethodDescription.Token asToken(ElementMatcher<? super TypeDescription> matcher) { TypeDescription.Generic receiverType = getReceiverType(); return new MethodDescription.Token(getInternalName(), getModifiers(), getTypeVariables().asTokenList(matcher), getReturnType().accept(new TypeDescription.Generic.Visitor.Substitutor.ForDetachment(matcher)), getParameters().asTokenList(matcher), getExceptionTypes().accept(new TypeDescription.Generic.Visitor.Substitutor.ForDetachment(matcher)), getDeclaredAnnotations(), getDefaultValue(), receiverType == null ? TypeDescription.Generic.UNDEFINED : receiverType.accept(new TypeDescription.Generic.Visitor.Substitutor.ForDetachment(matcher))); }
/** * {@inheritDoc} */ public boolean isInvokeBootstrap() { TypeDescription returnType = getReturnType().asErasure(); if ((isMethod() && (!isStatic() || !(JavaType.CALL_SITE.getTypeStub().isAssignableFrom(returnType) || JavaType.CALL_SITE.getTypeStub().isAssignableTo(returnType)))) || (isConstructor() && !JavaType.CALL_SITE.getTypeStub().isAssignableFrom(getDeclaringType().asErasure()))) { return false; } return isBootstrap(JavaType.METHOD_TYPE.getTypeStub()); }
/** * {@inheritDoc} */ public boolean isSpecializableFor(TypeDescription targetType) { if (isStatic()) { // Static private methods are never specializable, check static property first return false; } else if (isPrivate() || isConstructor()) { return getDeclaringType().equals(targetType); } else { return !isAbstract() && getDeclaringType().asErasure().isAssignableFrom(targetType); } }
/** * {@inheritDoc} */ public boolean isDefaultMethod() { return !isAbstract() && !isBridge() && getDeclaringType().isInterface(); }
/** * {@inheritDoc} */ public boolean isVisibleTo(TypeDescription typeDescription) { return (isVirtual() || getDeclaringType().asErasure().isVisibleTo(typeDescription)) && (isPublic() || typeDescription.equals(getDeclaringType().asErasure()) || isProtected() && getDeclaringType().asErasure().isAssignableFrom(typeDescription) || !isPrivate() && typeDescription.isSamePackage(getDeclaringType().asErasure())); }
/** * {@inheritDoc} */ public boolean isTypeInitializer() { return TYPE_INITIALIZER_INTERNAL_NAME.equals(getInternalName()); }
/** * {@inheritDoc} */ public boolean represents(Method method) { return equals(new ForLoadedMethod(method)); }
/** * {@inheritDoc} */ public boolean isInvokableOn(TypeDescription typeDescription) { return !isStatic() && !isTypeInitializer() && isVisibleTo(typeDescription) && (isVirtual() ? getDeclaringType().asErasure().isAssignableFrom(typeDescription) : getDeclaringType().asErasure().equals(typeDescription)); }
/** * {@inheritDoc} */ public boolean isAccessibleTo(TypeDescription typeDescription) { return (isVirtual() || getDeclaringType().asErasure().isVisibleTo(typeDescription)) && (isPublic() || typeDescription.equals(getDeclaringType().asErasure()) || !isPrivate() && typeDescription.isSamePackage(getDeclaringType().asErasure())) || isPrivate() && typeDescription.isNestMateOf(getDeclaringType().asErasure()); }
/** * {@inheritDoc} */ public boolean isConstructor() { return CONSTRUCTOR_INTERNAL_NAME.equals(getInternalName()); }
@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(); }
@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 SignatureToken asSignatureToken() { return new SignatureToken(getInternalName(), getReturnType().asErasure(), getParameters().asTypeList().asErasures()); }
/** * {@inheritDoc} */ public <T> T accept(TypeVariableSource.Visitor<T> visitor) { return visitor.onMethod(this.asDefined()); }
/** * {@inheritDoc} */ public int getActualModifiers(boolean manifest) { return manifest ? getActualModifiers() & ~(Opcodes.ACC_ABSTRACT | Opcodes.ACC_NATIVE) : getActualModifiers() & ~Opcodes.ACC_NATIVE | Opcodes.ACC_ABSTRACT; }