/** * Creates a new delegation processor. * * @param parameterBinders A list of parameter binder delegates. Each such delegate is responsible for creating * a {@link net.bytebuddy.implementation.bind.MethodDelegationBinder.ParameterBinding} * for a specific annotation. * @return A corresponding delegation processor. */ protected static DelegationProcessor of(List<? extends ParameterBinder<?>> parameterBinders) { Map<TypeDescription, ParameterBinder<?>> parameterBinderMap = new HashMap<TypeDescription, ParameterBinder<?>>(); for (ParameterBinder<?> parameterBinder : parameterBinders) { if (parameterBinderMap.put(TypeDescription.ForLoadedType.of(parameterBinder.getHandledType()), parameterBinder) != null) { throw new IllegalArgumentException("Attempt to bind two handlers to " + parameterBinder.getHandledType()); } } return new DelegationProcessor(parameterBinderMap); }
/** * {@inheritDoc} */ public MethodDelegationBinder.Record compile(MethodDescription candidate) { if (IgnoreForBinding.Verifier.check(candidate)) { return MethodDelegationBinder.Record.Illegal.INSTANCE; } List<DelegationProcessor.Handler> handlers = new ArrayList<DelegationProcessor.Handler>(candidate.getParameters().size()); for (ParameterDescription parameterDescription : candidate.getParameters()) { handlers.add(delegationProcessor.prepare(parameterDescription)); } return new Record(candidate, handlers, RuntimeType.Verifier.check(candidate)); }
/** * Creates a new method delegation binder that binds method based on annotations found on the target method. * * @param parameterBinders A list of parameter binder delegates. Each such delegate is responsible for creating a * {@link net.bytebuddy.implementation.bind.MethodDelegationBinder.ParameterBinding} * for a specific annotation. * @return An appropriate method delegation binder. */ public static MethodDelegationBinder of(List<? extends ParameterBinder<?>> parameterBinders) { return new TargetMethodAnnotationDrivenBinder(DelegationProcessor.of(parameterBinders)); }