/** * {@inheritDoc} */ public AnnotationList getDeclaredAnnotations() { return bridgeTarget.getDeclaredAnnotations(); }
/** * {@inheritDoc} */ public AnnotationList getDeclaredAnnotations() { return bridgeTarget.getDeclaredAnnotations(); }
/** * {@inheritDoc} */ public AnnotationList getDeclaredAnnotations() { return methodDescription.getDeclaredAnnotations(); }
/** * Validates if a method should be ignored for binding. * * @param methodDescription The method to validate. * @return {@code true} if the method should not be considered for binding. */ public static boolean check(MethodDescription methodDescription) { return methodDescription.getDeclaredAnnotations().isAnnotationPresent(IgnoreForBinding.class); } }
/** * {@inheritDoc} */ public Resolution resolve(MethodDescription source, MethodDelegationBinder.MethodBinding left, MethodDelegationBinder.MethodBinding right) { int leftPriority = resolve(left.getTarget().getDeclaredAnnotations().ofType(BindingPriority.class)); int rightPriority = resolve(right.getTarget().getDeclaredAnnotations().ofType(BindingPriority.class)); if (leftPriority == rightPriority) { return Resolution.AMBIGUOUS; } else if (leftPriority < rightPriority) { return Resolution.RIGHT; } else { return Resolution.LEFT; } } }
/** * Creates a method attribute appender factory that writes all annotations of a given method, both the method * annotations themselves and all annotations that are defined for every parameter. * * @param methodDescription The method from which to extract the annotations. * @return A method attribute appender factory for an appender that writes all annotations of the supplied method. */ public static Factory of(MethodDescription methodDescription) { ParameterList<?> parameters = methodDescription.getParameters(); List<MethodAttributeAppender.Factory> methodAttributeAppenders = new ArrayList<MethodAttributeAppender.Factory>(parameters.size() + 1); methodAttributeAppenders.add(new Explicit(methodDescription.getDeclaredAnnotations())); for (ParameterDescription parameter : parameters) { methodAttributeAppenders.add(new Explicit(parameter.getIndex(), parameter.getDeclaredAnnotations())); } return new Factory.Compound(methodAttributeAppenders); }
@Override protected NamingParameters getNamingParameters(MethodDescription instrumentedMethod) { if (instrumentedMethod.getDeclaredAnnotations().isAnnotationPresent(Timed.class)) { final Timed timed = instrumentedMethod.getDeclaredAnnotations().ofType(Timed.class).loadSilent(); return new NamingParameters(timed.name(), timed.absolute()); } else { return new NamingParameters("", false); } }
private AnnotationList doGetAnnotations() { AnnotationDescription.Loadable<Access> access = fieldDescription.getDeclaringType().asErasure() .getDeclaredAnnotations().ofType( Access.class ); if ( access != null && access.loadSilent().value() == AccessType.PROPERTY ) { Optional<MethodDescription> getter = getGetter(); if ( getter.isPresent() ) { return getter.get().getDeclaredAnnotations(); } else { return fieldDescription.getDeclaredAnnotations(); } } else if ( access != null && access.loadSilent().value() == AccessType.FIELD ) { return fieldDescription.getDeclaredAnnotations(); } else { Optional<MethodDescription> getter = getGetter(); // Note that the order here is important List<AnnotationDescription> annotationDescriptions = new ArrayList<>(); if ( getter.isPresent() ) { annotationDescriptions.addAll( getter.get().getDeclaredAnnotations() ); } annotationDescriptions.addAll( fieldDescription.getDeclaredAnnotations() ); return fieldDescription.getDeclaredAnnotations(); } } }
@Override protected NamingParameters getNamingParameters(MethodDescription instrumentedMethod) { final Metered metered = instrumentedMethod.getDeclaredAnnotations().ofType(Metered.class).loadSilent(); return new NamingParameters(metered.name(), metered.absolute()); }
@Override protected NamingParameters getNamingParameters(MethodDescription instrumentedMethod) { final ExceptionMetered exceptionMetered = instrumentedMethod.getDeclaredAnnotations().ofType(ExceptionMetered.class).loadSilent(); return new NamingParameters(exceptionMetered.name(), exceptionMetered.absolute()); }
@Override public Target resolve(TypeDescription instrumentedType, MethodDescription instrumentedMethod, Assigner assigner, Advice.ArgumentHandler argumentHandler, Sort sort) { final ExceptionMetered exceptionMetered = instrumentedMethod.getDeclaredAnnotations().ofType(ExceptionMetered.class).loadSilent(); final TypeDescription.ForLoadedType exceptionType = new TypeDescription.ForLoadedType(exceptionMetered.cause()); return Target.ForStackManipulation.of(exceptionType); } };
public static String getRequestName(MethodDescription instrumentedMethod) { final AnnotationDescription.Loadable<Traced> monitorRequestsLoadable = instrumentedMethod .getDeclaredAnnotations() .ofType(Traced.class); if (monitorRequestsLoadable != null) { final Traced traced = monitorRequestsLoadable.loadSilent(); if (!traced.requestName().isEmpty()) { return traced.requestName(); } if (traced.resolveNameAtRuntime()) { return null; } } return getBusinessTransationName(instrumentedMethod.getDeclaringType().getTypeName(), instrumentedMethod.getName()); }
AnnotationAppender.ForTypeAnnotations.VARIABLE_ON_INVOKEABLE, methodDescription.getTypeVariables()); for (AnnotationDescription annotation : methodDescription.getDeclaredAnnotations().filter(not(annotationType(nameStartsWith("jdk.internal."))))) { annotationAppender = annotationAppender.append(annotation, annotationValueFilter);
/** * @see me.seeber.gradle.ide.eclipse.annotations.Nullability#getReturnValueNullability(net.bytebuddy.description.method.MethodDescription) */ @Override public Nullness getReturnValueNullability(MethodDescription method) { Nullness nullability = getNullability(method.getDeclaredAnnotations()); return nullability; }
/** * @see me.seeber.gradle.ide.eclipse.annotations.Nullability#getReturnValueNullability(net.bytebuddy.description.method.MethodDescription) */ @Override public Nullness getReturnValueNullability(MethodDescription method) { Nullness nullability = getNullability(method.getDeclaredAnnotations()); return nullability; }
@Nullable private Object getAnnotationValue(MethodDescription instrumentedMethod, AnnotationValueExtractor annotationValueExtractor) { for (TypeDescription typeDescription : instrumentedMethod.getDeclaredAnnotations().asTypeList()) { if (named(annotationValueExtractor.annotationClassName()).matches(typeDescription)) { for (MethodDescription.InDefinedShape annotationMethod : typeDescription.getDeclaredMethods()) { if (annotationMethod.getName().equals(annotationValueExtractor.method())) { return instrumentedMethod.getDeclaredAnnotations().ofType(typeDescription).getValue(annotationMethod).resolve(); } } } } return null; }
private AnnotationList doGetAnnotations() { AnnotationDescription.Loadable<Access> access = fieldDescription.getDeclaringType().asErasure() .getDeclaredAnnotations().ofType( Access.class ); if ( access != null && access.loadSilent().value() == AccessType.PROPERTY ) { Optional<MethodDescription> getter = getGetter(); if ( getter.isPresent() ) { return getter.get().getDeclaredAnnotations(); } else { return fieldDescription.getDeclaredAnnotations(); } } else if ( access != null && access.loadSilent().value() == AccessType.FIELD ) { return fieldDescription.getDeclaredAnnotations(); } else { Optional<MethodDescription> getter = getGetter(); // Note that the order here is important List<AnnotationDescription> annotationDescriptions = new ArrayList<>(); if ( getter.isPresent() ) { annotationDescriptions.addAll( getter.get().getDeclaredAnnotations() ); } annotationDescriptions.addAll( fieldDescription.getDeclaredAnnotations() ); return fieldDescription.getDeclaredAnnotations(); } } }
public static String getRequestName(MethodDescription instrumentedMethod) { final AnnotationDescription.Loadable<MonitorRequests> monitorRequestsLoadable = instrumentedMethod .getDeclaredAnnotations() .ofType(MonitorRequests.class); if (monitorRequestsLoadable != null) { final MonitorRequests monitorRequests = monitorRequestsLoadable.loadSilent(); if (!monitorRequests.requestName().isEmpty()) { return monitorRequests.requestName(); } if (monitorRequests.resolveNameAtRuntime()) { return null; } } return getBusinessTransationName(instrumentedMethod.getDeclaringType().getTypeName(), instrumentedMethod.getName()); }