List of usage examples for java.lang.reflect Method getParameterTypes
@Override
public Class<?>[] getParameterTypes()
From source file:io.ingenieux.lambada.invoker.UserHandlerFactory.java
protected boolean hasParameterTypes(Method m, Class<?>... types) { int i = 0;/*from w w w.j av a 2 s.c o m*/ for (Class<?> t : types) { if (!t.equals(m.getParameterTypes()[i])) { return false; } i++; } return true; }
From source file:com.flowpowered.cerealization.config.annotated.AnnotatedObjectConfiguration.java
private void invokeMethods(Set<Method> methods, Object target, ConfigurationNode nodeParam) throws ConfigurationException { for (Method method : methods) { method.setAccessible(true);// w w w . ja va2 s. c o m Class<?>[] parameters = method.getParameterTypes(); if (parameters.length == 0 || !ConfigurationNode.class.isAssignableFrom(parameters[0])) { continue; } try { method.invoke(target, nodeParam); } catch (IllegalAccessException ex) { throw new ConfigurationException(ex); } catch (InvocationTargetException ex) { throw new ConfigurationException(ex); } } }
From source file:com.swtxml.util.reflector.MethodQuery.java
private String getSignature(Method method) { StringBuffer s = new StringBuffer(); s.append(method.getName());/*ww w .j a v a2 s .c om*/ for (Class<?> param : method.getParameterTypes()) { s.append(':'); s.append(param.getName()); } return s.toString(); }
From source file:edu.vt.middleware.ldap.props.AbstractPropertyInvoker.java
/** * Initializes the properties map with the supplied class. * * @param c to read methods from/*ww w. jav a 2 s . c o m*/ * @param domain optional domain that properties are in */ protected void initialize(final Class<?> c, final String domain) { final String cacheKey = new StringBuilder(c.getName()).append("@").append(domain).toString(); if (PROPERTIES_CACHE.containsKey(cacheKey)) { this.properties = PROPERTIES_CACHE.get(cacheKey); } else { this.properties = new HashMap<String, Method[]>(); PROPERTIES_CACHE.put(cacheKey, this.properties); for (Method method : c.getMethods()) { if (method.getName().startsWith("set") && method.getParameterTypes().length == 1) { final String mName = method.getName().substring(3); final String pName = new StringBuilder(domain).append(mName.substring(0, 1).toLowerCase()) .append(mName.substring(1, mName.length())).toString(); if (this.properties.containsKey(pName)) { final Method[] m = this.properties.get(pName); m[1] = method; this.properties.put(pName, m); } else { this.properties.put(pName, new Method[] { null, method }); } } else if (method.getName().startsWith("get") && method.getParameterTypes().length == 0) { final String mName = method.getName().substring(3); final String pName = new StringBuilder(domain).append(mName.substring(0, 1).toLowerCase()) .append(mName.substring(1, mName.length())).toString(); if (this.properties.containsKey(pName)) { final Method[] m = this.properties.get(pName); m[0] = method; this.properties.put(pName, m); } else { this.properties.put(pName, new Method[] { method, null }); } } else if ("initialize".equals(method.getName()) && method.getParameterTypes().length == 0) { final String pName = new StringBuilder(domain).append(method.getName()).toString(); this.properties.put(pName, new Method[] { method, method }); } } } this.clazz = c; }
From source file:de.doncarnage.minecraft.common.commandhandler.manager.impl.DefaultCommandManager.java
private void checkForRightMethodFormat(CommandHolder commandHolder, Method method) { List<Class<?>> params = Arrays.asList(method.getParameterTypes()); if (params.size() != 2 || !params.contains(CommandSender.class) || !params.contains(CommandContext.class)) { String paramString = buildParamString(params); throw new IllegalStateException(String.format( "The method %s in class %s does not have the needed arguments. Current arguments (%d): %s", method.getName(), commandHolder.getClass().getName(), params.size(), paramString)); }// www . ja v a 2s .c o m }
From source file:org.LexGrid.LexBIG.caCore.client.proxy.LexEVSApplicationServiceProxy.java
/** * Returns a list of class names that are parameters to the given method. * @param methodImpl/*from w ww. j av a 2 s .c om*/ * @return list of fully-qualified class names */ private String[] getParameterTypes(Method methodImpl) { String[] paramClasses = new String[methodImpl.getParameterTypes().length]; int i = 0; for (Class paramClass : methodImpl.getParameterTypes()) { if (paramClass == null) continue; paramClasses[i++] = paramClass.getName(); } return paramClasses; }
From source file:pl.bristleback.server.bristle.conf.resolver.action.client.ClientActionResolver.java
private List<ClientActionParameterInformation> resolveActionParameters(Method actionMethod) { SerializationResolver serializationResolver = serializationEngine.getSerializationResolver(); List<ClientActionParameterInformation> parameters = new ArrayList<ClientActionParameterInformation>(); for (int i = 0; i < actionMethod.getParameterTypes().length; i++) { Type parameterType = actionMethod.getGenericParameterTypes()[i]; ClientActionParameterInformation parameterInformation = parameterResolver.prepareActionParameter( serializationResolver, parameterType, actionMethod.getParameterAnnotations()[i]); parameters.add(parameterInformation); }/*from w w w . j a v a 2s . com*/ return parameters; }
From source file:com.laxser.blitz.web.paramresolver.MethodParameterResolver.java
public MethodParameterResolver(Class<?> controllerClazz, Method method, ParameterNameDiscovererImpl parameterNameDiscoverer, ResolverFactory resolverFactory) { this.method = method; Class<?>[] parameterTypes = method.getParameterTypes(); parameterNames = parameterNameDiscoverer.getParameterNames(method); resolvers = new ParamResolver[parameterTypes.length]; paramMetaDatas = new ParamMetaData[parameterTypes.length]; // //from w w w. j a v a2 s .c om for (int i = 0; i < parameterTypes.length; i++) { ParamMetaDataImpl paramMetaData = new ParamMetaDataImpl(controllerClazz, method, parameterTypes[i], parameterNames[i], i); paramMetaDatas[i] = paramMetaData; resolvers[i] = resolverFactory.supports(paramMetaData); } }
From source file:com.drillmap.crm.repository.extensions.invoker.ReflectionRepositoryInvoker.java
@Override public void invokeDelete(Serializable id) { Method method = methods.getDeleteMethod(); if (method.getParameterTypes()[0].equals(Serializable.class)) { invoke(method, convertId(id));/*w ww . ja va2 s . com*/ } else { invoke(method, invokeFindOne(id)); } }