List of usage examples for java.lang Void TYPE
Class TYPE
To view the source code for java.lang Void TYPE.
Click Source Link
From source file:org.apache.camel.component.bean.MethodInfo.java
public MethodInvocation createMethodInvocation(final Object pojo, final Exchange exchange) { final Object[] arguments = parametersExpression.evaluate(exchange, Object[].class); return new MethodInvocation() { public Method getMethod() { return method; }/*from ww w .jav a2 s . com*/ public Object[] getArguments() { return arguments; } public Object proceed(AsyncCallback callback, AtomicBoolean doneSync) throws Exception { // dynamic router should be invoked beforehand if (dynamicRouter != null) { if (!dynamicRouter.isStarted()) { ServiceHelper.startService(dynamicRouter); } // use a expression which invokes the method to be used by dynamic router Expression expression = new DynamicRouterExpression(pojo); boolean sync = dynamicRouter.doRoutingSlip(exchange, expression, callback); // must remember the done sync returned from the dynamic router doneSync.set(sync); return Void.TYPE; } // invoke pojo if (LOG.isTraceEnabled()) { LOG.trace(">>>> invoking: " + method + " on bean: " + pojo + " with arguments: " + asString(arguments) + " for exchange: " + exchange); } Object result = invoke(method, pojo, arguments, exchange); if (recipientList != null) { // ensure its started if (!recipientList.isStarted()) { ServiceHelper.startService(recipientList); } boolean sync = recipientList.sendToRecipientList(exchange, result, callback); // must remember the done sync returned from the recipient list doneSync.set(sync); // we don't want to return the list of endpoints // return Void to indicate to BeanProcessor that there is no reply return Void.TYPE; } if (routingSlip != null) { if (!routingSlip.isStarted()) { ServiceHelper.startService(routingSlip); } boolean sync = routingSlip.doRoutingSlip(exchange, result, callback); // must remember the done sync returned from the routing slip doneSync.set(sync); return Void.TYPE; } return result; } public Object getThis() { return pojo; } public AccessibleObject getStaticPart() { return method; } }; }
From source file:org.apache.camel.maven.AbstractApiMethodGeneratorMojo.java
public static boolean isVoidType(Class<?> resultType) { return resultType == Void.TYPE; }
From source file:org.assertj.assertions.generator.util.ClassUtil.java
public static boolean isStandardGetter(Method method) { return isValidStandardGetterName(method.getName()) && !Void.TYPE.equals(method.getReturnType()) && method.getParameterTypes().length == 0; }
From source file:org.projectforge.continuousdb.TableAttribute.java
/** * @param method//from ww w . ja v a 2 s. c o m * @return */ private void setGenericReturnType(final Method method) { Type returnType = method.getGenericReturnType(); if ((returnType instanceof ParameterizedType) == false) { return; } final ParameterizedType type = (ParameterizedType) returnType; OneToMany oneToMany = method.getAnnotation(OneToMany.class); if (oneToMany != null && oneToMany.targetEntity() != null && oneToMany.targetEntity() != Void.TYPE) { if (type.getRawType() instanceof Class) { if (List.class.isAssignableFrom((Class) type.getRawType()) == true) { genericType = oneToMany.targetEntity(); return; } } } final Type[] typeArguments = type.getActualTypeArguments(); if (typeArguments.length == 0) { return; } if (typeArguments[0] instanceof ParameterizedType) { final ParameterizedType nt = (ParameterizedType) typeArguments[0]; final Type[] nst = nt.getActualTypeArguments(); if (nst.length > 0) { final Class<?> typeArgClass = (Class<?>) nst[0]; if (log.isDebugEnabled() == true) { log.debug("Generic type found for '" + entityClass + "." + property + "': '" + typeArgClass + "'."); } genericType = typeArgClass; } } if ((typeArguments[0] instanceof Class) == false) { // opps final Class<?> thclas = typeArguments[0].getClass(); log.error("Cannot determine entity type: " + thclas.getName() + " in method: " + method); } else { final Class<?> typeArgClass = (Class<?>) typeArguments[0]; if (log.isDebugEnabled() == true) { log.debug("Generic type found for '" + entityClass + "." + property + "': '" + typeArgClass + "'."); } genericType = typeArgClass; } }
From source file:padl.util.Util.java
public static List getPatternProperties(final Class clazz) { final List roProperties = new ArrayList(); final List rwProperties = new ArrayList(); final List exProperties = new ArrayList(); try {/*www .j a v a 2 s .c o m*/ final PropertyDescriptor[] basicProperties = Introspector.getBeanInfo(clazz, null) .getPropertyDescriptors(); for (int x = 0; x < basicProperties.length; x++) { final Method writeMethod = basicProperties[x].getWriteMethod(); final Method readMethod = basicProperties[x].getReadMethod(); if (readMethod != null) { if (writeMethod != null) { rwProperties.add(basicProperties[x].getName()); } else { roProperties.add(basicProperties[x].getName()); } } } } catch (final Exception e) { } // I look for all suitable "add" and "remove" methods. try { final Map adds = new HashMap(); final Map removes = new HashMap(); final Method[] methods = clazz.getMethods(); for (int i = 0; i < methods.length; i++) { final Method currentMethod = methods[i]; final int mods = currentMethod.getModifiers(); final String currentName = currentMethod.getName(); final Class argTypes[] = currentMethod.getParameterTypes(); if (Modifier.isStatic(mods) || !Modifier.isPublic(mods) // || // argTypes.length // != 1 || currentMethod.getReturnType() != Void.TYPE) { continue; // RV: pour que Yann soit content !!!! } // Yann 2001/06/27: I check the number of arguments // depending on which type of method I am looking at // to handle correctly the add and remove methods // of the Faade pattern. if (currentName.startsWith("add") && argTypes.length > 0) { adds.put(new String(currentName.substring(3) + ":" + argTypes[0]), currentMethod); } else if (currentName.startsWith("remove") && argTypes.length == 1) { removes.put(new String(currentName.substring(6) + ":" + argTypes[0]), currentMethod); } } // Now I look for matching add + remove pairs. final Iterator keys = adds.keySet().iterator(); while (keys.hasNext()) { final String addKey = (String) keys.next(); // Skip any "add" which doesn't have a matching "remove". if (removes.get(addKey) != null) { exProperties.add(addKey.substring(0, addKey.indexOf(":"))); } } } catch (final Exception e) { e.printStackTrace(ProxyConsole.getInstance().errorOutput()); } final List props = roProperties; props.addAll(rwProperties); props.addAll(exProperties); return props; }
From source file:io.swagger.jaxrs.MethodProcessor.java
private static boolean isVoid(Type type) { final Class<?> cls = TypeFactory.defaultInstance().constructType(type).getRawClass(); return Void.class.isAssignableFrom(cls) || Void.TYPE.isAssignableFrom(cls); }
From source file:org.apache.openejb.util.proxy.QueryProxy.java
private void persist(final Object[] args, final Class<?> returnType) { if (args != null && args.length == 1 && returnType.equals(Void.TYPE)) { em.persist(args[0]);//w w w. j a va 2 s . co m } else { throw new IllegalArgumentException(PERSIST_NAME + " should have only one parameter and return void"); } }
From source file:com.gargoylesoftware.htmlunit.SimpleWebTestCase.java
/** * From Junit. Test if the method is a junit test. * @param method the method/*from w ww.j a va 2 s .c o m*/ * @return <code>true</code> if this is a junit test */ private boolean isPublicTestMethod(final Method method) { return method.getParameterTypes().length == 0 && (method.getName().startsWith("test") || method.getAnnotation(Test.class) != null) && method.getReturnType() == Void.TYPE && Modifier.isPublic(method.getModifiers()); }
From source file:ch.ralscha.extdirectspring.controller.RouterControllerOptionalTest.java
@Test public void testMethod19() { ControllerUtil.sendAndReceive(mockMvc, null, Collections.singletonList(new Cookie("stringCookie", "aString")), "remoteProviderOptional", "method19", "aString", (Object[]) null); ControllerUtil.sendAndReceive(mockMvc, null, null, "remoteProviderOptional", "method19", Void.TYPE, (Object[]) null);//from w w w . j a va 2 s . c om }
From source file:com.hablutzel.cmdline.CommandLineApplication.java
/** * Validate a Method to be a main command line application method. * * Methods with more than 1 argument are not allowed. Methods with return types * are not allowed. Methods that throw an exception other than * org.apache.commons.cli.CommandLineException are not allowed, * * @param method the method to validate// w ww. j av a 2s . co m * @return A new method helper for the method */ private CommandLineMethodHelper getHelperForCommandLineMain(Method method) throws CommandLineException { // Validate that the return type is a void if (!method.getReturnType().equals(Void.TYPE)) { throw new CommandLineException("For method " + method.getName() + ", the return type is not void"); } // Validate the exceptions throws by the method for (Class<?> clazz : method.getExceptionTypes()) { if (!clazz.equals(CommandLineException.class)) { throw new CommandLineException("For method " + method.getName() + ", there is an invalid exception class " + clazz.getName()); } } // In order to get ready to create the configuration instance, // we will need to know the command line option type // and the element type. Class<?> elementClass; MethodType methodType; Converter converter; // Get the parameters of the method. We'll use these to // determine what type of option we have - scalar, boolean, etc. Class<?> parameterClasses[] = method.getParameterTypes(); // See what the length tells us switch (parameterClasses.length) { case 0: throw new CommandLineException("Main command line method must take arguments"); case 1: { // For a method with one argument, we have to look // more closely at the argument. It has to be a simple // scalar object, an array, or a list. Class<?> parameterClass = parameterClasses[0]; if (parameterClass.isArray()) { // For an array, we get the element class based on the // underlying component type methodType = MethodType.Array; elementClass = parameterClass.getComponentType(); } else { // For a scalar, we get the element type from the // type of the parameter. methodType = MethodType.Scalar; elementClass = parameterClass.getClass(); } // Now that we have the element type, make sure it's convertable converter = ConvertUtils.lookup(String.class, elementClass); if (converter == null) { throw new CommandLineException("Cannot find a conversion from String to " + elementClass.getName() + " for method " + method.getName()); } break; } default: { // Other method types not allowed. throw new CommandLineException("Method " + method.getName() + " has too many arguments"); } } // Now we can return the configuration for this method return new CommandLineMethodHelper(method, methodType, elementClass, converter); }