@Override public boolean matches(Method method, Class<?> targetClass) { return (method.getName().startsWith("get") && method.getParameterCount() == 0); }
/** * Returns {@code true} if the supplied '{@code candidateMethod}' can be * consider a validate candidate for the {@link Method} that is {@link Method#isBridge() bridged} * by the supplied {@link Method bridge Method}. This method performs inexpensive * checks and can be used quickly filter for a set of possible matches. */ private static boolean isBridgedCandidateFor(Method candidateMethod, Method bridgeMethod) { return (!candidateMethod.isBridge() && !candidateMethod.equals(bridgeMethod) && candidateMethod.getName().equals(bridgeMethod.getName()) && candidateMethod.getParameterCount() == bridgeMethod.getParameterCount()); }
/** * Determine whether the given method is a "finalize" method. * @see java.lang.Object#finalize() */ public static boolean isFinalizeMethod(@Nullable Method method) { return (method != null && method.getName().equals("finalize") && method.getParameterCount() == 0); }
@Override public boolean matches(Method method, Class<?> targetClass) { return (method.getName().startsWith("set") && method.getParameterCount() == 1 && method.getReturnType() == Void.TYPE); }
/** * Determine if the supplied method is an "annotationType" method. * @return {@code true} if the method is an "annotationType" method * @since 4.2 * @see Annotation#annotationType() */ static boolean isAnnotationTypeMethod(@Nullable Method method) { return (method != null && method.getName().equals("annotationType") && method.getParameterCount() == 0); }
/** * Determine whether the given method is a "toString" method. * @see java.lang.Object#toString() */ public static boolean isToStringMethod(@Nullable Method method) { return (method != null && method.getName().equals("toString") && method.getParameterCount() == 0); }
public static boolean isSetBeanFactory(Method candidateMethod) { return (candidateMethod.getName().equals("setBeanFactory") && candidateMethod.getParameterCount() == 1 && BeanFactory.class == candidateMethod.getParameterTypes()[0] && BeanFactoryAware.class.isAssignableFrom(candidateMethod.getDeclaringClass())); } }
public LifecycleElement(Method method) { if (method.getParameterCount() != 0) { throw new IllegalStateException("Lifecycle method annotation requires a no-arg method: " + method); } this.method = method; this.identifier = (Modifier.isPrivate(method.getModifiers()) ? ClassUtils.getQualifiedMethodName(method) : method.getName()); }
/** * Return a short representation of this handler method for log message purposes. * @since 4.3 */ public String getShortLogMessage() { return getBeanType().getName() + "#" + this.method.getName() + "[" + this.method.getParameterCount() + " args]"; }
/** * Return a short representation of this handler method for log message purposes. */ public String getShortLogMessage() { int args = this.method.getParameterCount(); return getBeanType().getName() + "#" + this.method.getName() + "[" + args + " args]"; }
/** * Create a new {@link MethodArgumentBuilder} instance. * @since 4.2 */ public MethodArgumentBuilder(@Nullable UriComponentsBuilder baseUrl, Class<?> controllerType, Method method) { Assert.notNull(controllerType, "'controllerType' is required"); Assert.notNull(method, "'method' is required"); this.baseUrl = baseUrl != null ? baseUrl : UriComponentsBuilder.fromPath(getPath()); this.controllerType = controllerType; this.method = method; this.argumentValues = new Object[method.getParameterCount()]; }
@Override public boolean matches(Method method, Class<?> targetClass) { return method.getParameterCount() == 1 && method.getParameterTypes()[0].equals(Integer.class); } },
private MethodParameter[] initMethodParameters() { int count = this.bridgedMethod.getParameterCount(); MethodParameter[] result = new MethodParameter[count]; for (int i = 0; i < count; i++) { HandlerMethodParameter parameter = new HandlerMethodParameter(i); GenericTypeResolver.resolveParameterType(parameter, this.beanType); result[i] = parameter; } return result; }
@Override public boolean matches(Method m, @Nullable Class<?> targetClass) { return m.getName().equals("overload") && m.getParameterCount() == 0; } });
@Override public boolean matches(Method m, @Nullable Class<?> targetClass) { return m.getParameterCount() == 0 || "exceptional".equals(m.getName()); } };
/** * Filter on methods with the given parameter types. */ public Builder<T> argTypes(Class<?>... argTypes) { addFilter("argTypes=" + Arrays.toString(argTypes), method -> ObjectUtils.isEmpty(argTypes) ? method.getParameterCount() == 0 : Arrays.equals(method.getParameterTypes(), argTypes)); return this; }
/** * Filter on methods with the given parameter types. */ public Builder<T> argTypes(Class<?>... argTypes) { addFilter("argTypes=" + Arrays.toString(argTypes), method -> ObjectUtils.isEmpty(argTypes) ? method.getParameterCount() == 0 : Arrays.equals(method.getParameterTypes(), argTypes)); return this; }
private List<MethodParameter> applyFilters() { List<MethodParameter> matches = new ArrayList<>(); for (int i = 0; i < method.getParameterCount(); i++) { MethodParameter param = new SynthesizingMethodParameter(method, i); param.initParameterNameDiscovery(nameDiscoverer); if (this.filters.stream().allMatch(p -> p.test(param))) { matches.add(param); } } return matches; } }
private List<MethodParameter> applyFilters() { List<MethodParameter> matches = new ArrayList<>(); for (int i = 0; i < method.getParameterCount(); i++) { MethodParameter param = new SynthesizingMethodParameter(method, i); param.initParameterNameDiscovery(nameDiscoverer); if (this.filters.stream().allMatch(p -> p.test(param))) { matches.add(param); } } return matches; } }
@Test public void testFindBridgedMethodInHierarchy() throws Exception { Method bridgeMethod = DateAdder.class.getMethod("add", Object.class); assertTrue(bridgeMethod.isBridge()); Method bridgedMethod = BridgeMethodResolver.findBridgedMethod(bridgeMethod); assertFalse(bridgedMethod.isBridge()); assertEquals("add", bridgedMethod.getName()); assertEquals(1, bridgedMethod.getParameterCount()); assertEquals(Date.class, bridgedMethod.getParameterTypes()[0]); }