本文整理了Java中java.lang.reflect.Method.getParameterCount()
方法的一些代码示例,展示了Method.getParameterCount()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Method.getParameterCount()
方法的具体详情如下:
包路径:java.lang.reflect.Method
类名称:Method
方法名:getParameterCount
暂无
代码示例来源:origin: spring-projects/spring-framework
@Override
public boolean matches(Method method, Class<?> targetClass) {
return (method.getName().startsWith("get") &&
method.getParameterCount() == 0);
}
代码示例来源:origin: spring-projects/spring-framework
/**
* 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());
}
代码示例来源:origin: spring-projects/spring-framework
/**
* 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);
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public boolean matches(Method method, Class<?> targetClass) {
return (method.getName().startsWith("set") &&
method.getParameterCount() == 1 &&
method.getReturnType() == Void.TYPE);
}
代码示例来源:origin: spring-projects/spring-framework
/**
* 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);
}
代码示例来源:origin: spring-projects/spring-framework
/**
* 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);
}
代码示例来源:origin: spring-projects/spring-framework
public static boolean isSetBeanFactory(Method candidateMethod) {
return (candidateMethod.getName().equals("setBeanFactory") &&
candidateMethod.getParameterCount() == 1 &&
BeanFactory.class == candidateMethod.getParameterTypes()[0] &&
BeanFactoryAware.class.isAssignableFrom(candidateMethod.getDeclaringClass()));
}
}
代码示例来源:origin: spring-projects/spring-framework
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());
}
代码示例来源:origin: spring-projects/spring-framework
/**
* 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]";
}
代码示例来源:origin: spring-projects/spring-framework
/**
* 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]";
}
代码示例来源:origin: spring-projects/spring-framework
/**
* 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()];
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public boolean matches(Method method, Class<?> targetClass) {
return method.getParameterCount() == 1 &&
method.getParameterTypes()[0].equals(Integer.class);
}
},
代码示例来源:origin: spring-projects/spring-framework
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;
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public boolean matches(Method m, @Nullable Class<?> targetClass) {
return m.getName().equals("overload") && m.getParameterCount() == 0;
}
});
代码示例来源:origin: spring-projects/spring-framework
@Override
public boolean matches(Method m, @Nullable Class<?> targetClass) {
return m.getParameterCount() == 0 || "exceptional".equals(m.getName());
}
};
代码示例来源:origin: spring-projects/spring-framework
/**
* 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;
}
代码示例来源:origin: spring-projects/spring-framework
/**
* 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;
}
代码示例来源:origin: spring-projects/spring-framework
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;
}
}
代码示例来源:origin: spring-projects/spring-framework
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;
}
}
代码示例来源:origin: spring-projects/spring-framework
@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]);
}
内容来源于网络,如有侵权,请联系作者删除!