Example usage for java.lang Void TYPE

List of usage examples for java.lang Void TYPE

Introduction

In this page you can find the example usage for java.lang Void TYPE.

Prototype

Class TYPE

To view the source code for java.lang Void TYPE.

Click Source Link

Document

The Class object representing the pseudo-type corresponding to the keyword void .

Usage

From source file:ch.ralscha.extdirectspring.controller.RouterControllerFormLoadTest.java

@Test
public void testFormLoadReturnsNull() {
    ControllerUtil.sendAndReceive(mockMvc, "remoteProviderFormLoad", "method2", null, Void.TYPE);
}

From source file:dk.clanie.actor.ActorExecutionInterceptor.java

public Object invoke(final MethodInvocation invocation) throws Throwable {
    @SuppressWarnings("rawtypes")
    Future result = this.executor.submit(new Callable<Object>() {
        public Object call() throws Exception {
            try {
                Object result = invocation.proceed();
                if (result instanceof Future) {
                    return ((Future) result).get();
                }//  ww w .  j  a v  a2s  . c o  m
            } catch (Throwable ex) {
                ReflectionUtils.rethrowException(ex);
            }
            return null;
        }
    });
    Class<?> returnType = invocation.getMethod().getReturnType();
    if (Future.class.isAssignableFrom(returnType)) {
        return result;
    } else if (Void.TYPE != returnType) {
        try {
            return result.get();
        } catch (Throwable ex) {
            ReflectionUtils.rethrowException(ex);
        }
    }
    return null;
}

From source file:com.emc.ecs.sync.config.ConfigWrapper.java

public ConfigWrapper(Class<C> targetClass) {
    try {//from   w w w .  j a va 2 s  .c o m
        this.targetClass = targetClass;
        if (targetClass.isAnnotationPresent(StorageConfig.class))
            this.uriPrefix = targetClass.getAnnotation(StorageConfig.class).uriPrefix();
        if (targetClass.isAnnotationPresent(FilterConfig.class))
            this.cliName = targetClass.getAnnotation(FilterConfig.class).cliName();
        if (targetClass.isAnnotationPresent(Label.class))
            this.label = targetClass.getAnnotation(Label.class).value();
        if (targetClass.isAnnotationPresent(Documentation.class))
            this.documentation = targetClass.getAnnotation(Documentation.class).value();
        BeanInfo beanInfo = Introspector.getBeanInfo(targetClass);
        for (PropertyDescriptor descriptor : beanInfo.getPropertyDescriptors()) {
            if (descriptor.getReadMethod().isAnnotationPresent(Option.class)) {
                propertyMap.put(descriptor.getName(), new ConfigPropertyWrapper(descriptor));
            }
        }
        for (MethodDescriptor descriptor : beanInfo.getMethodDescriptors()) {
            Method method = descriptor.getMethod();
            if (method.isAnnotationPresent(UriParser.class)) {
                if (method.getReturnType().equals(Void.TYPE) && method.getParameterTypes().length == 1
                        && method.getParameterTypes()[0].equals(String.class)) {
                    uriParser = method;
                } else {
                    log.warn("illegal signature for @UriParser method {}.{}", targetClass.getSimpleName(),
                            method.getName());
                }
            } else if (method.isAnnotationPresent(UriGenerator.class)) {
                if (method.getReturnType().equals(String.class) && method.getParameterTypes().length == 0) {
                    uriGenerator = method;
                } else {
                    log.warn("illegal signature for @UriGenerator method {}.{}", targetClass.getSimpleName(),
                            method.getName());
                }
            }
        }
        if (propertyMap.isEmpty())
            log.info("no @Option annotations found in {}", targetClass.getSimpleName());
    } catch (IntrospectionException e) {
        throw new RuntimeException(e);
    }
}

From source file:net.mindengine.oculus.frontend.web.controllers.api.ApiController.java

@Override
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
    Map<String, Object> model = new HashMap<String, Object>();

    response.addHeader("Content-Type", "application/json");

    if (userIsAuthorized(request)) {
        MatchedMethod matchedMethod = findMatchedMethod(request);
        Object[] arguments = createMethodArguments(matchedMethod, request, response);

        try {// ww w  .  j  a v a  2s.c  o m
            Object result = matchedMethod.getMethod().invoke(this, arguments);
            if (matchedMethod.getMethod().getReturnType().equals(Void.TYPE)) {
                return null;
            } else
                model.put("response", result);
        } catch (InvocationTargetException e) {
            response.setStatus(400);
            model.put("response", new ApiError(
                    e.getTargetException().getClass().getName() + ": " + e.getTargetException().getMessage()));
            e.getTargetException().printStackTrace();
        }
    } else {
        response.setStatus(401);
        model.put("response", new ApiError("You are not authorized for this request."));
    }

    return new ModelAndView("jsonView", model);
}

From source file:org.vaadin.spring.i18n.Translator.java

private void analyzeMethods(Class<?> clazz) {
    for (Method m : clazz.getDeclaredMethods()) {
        if (m.getParameterTypes().length == 0 && m.getReturnType() != Void.TYPE) {
            if (m.isAnnotationPresent(TranslatedProperty.class)) {
                translatedMethods.put(m.getAnnotation(TranslatedProperty.class), m);
            } else if (m.isAnnotationPresent(TranslatedProperties.class)) {
                for (TranslatedProperty annotation : m.getAnnotation(TranslatedProperties.class).value()) {
                    translatedMethods.put(annotation, m);
                }/*from  www .  j  a va2s  .c  o  m*/
            }
        }
    }
}

From source file:springfox.documentation.swagger.readers.operation.OperationResponseClassReader.java

private ModelRef modelRef(ResolvedType type, ModelContext modelContext) {
    if (isContainerType(type)) {
        ResolvedType collectionElementType = collectionElementType(type);
        String elementTypeName = nameExtractor.typeName(fromParent(modelContext, collectionElementType));
        return new ModelRef(containerType(type), elementTypeName);
    }//from  w ww  . j a va2  s .c om
    if (isMapType(type)) {
        String elementTypeName = nameExtractor.typeName(fromParent(modelContext, mapValueType(type)));
        return new ModelRef("Map", elementTypeName, true);
    }
    if (Void.class.equals(type.getErasedType()) || Void.TYPE.equals(type.getErasedType())) {
        new ModelRef("void");
    }
    String typeName = nameExtractor.typeName(fromParent(modelContext, type));
    return new ModelRef(typeName);
}

From source file:ch.ralscha.extdirectspring.util.MethodInfo.java

public MethodInfo(Class<?> clazz, ApplicationContext context, String beanName, Method method) {

    ExtDirectMethod extDirectMethodAnnotation = AnnotationUtils.findAnnotation(method, ExtDirectMethod.class);

    this.type = extDirectMethodAnnotation.value();

    if (extDirectMethodAnnotation.jsonView() != ExtDirectMethod.NoJsonView.class) {
        this.jsonView = extDirectMethodAnnotation.jsonView();
    } else {/*from   ww  w .j  av  a2s.  com*/
        this.jsonView = null;
    }

    if (StringUtils.hasText(extDirectMethodAnnotation.group())) {
        this.group = extDirectMethodAnnotation.group().trim();
    } else {
        this.group = null;
    }

    this.synchronizeOnSession = extDirectMethodAnnotation.synchronizeOnSession();
    this.streamResponse = extDirectMethodAnnotation.streamResponse();

    if (this.type != ExtDirectMethodType.FORM_POST) {
        this.method = method;
        this.parameters = buildParameterList(clazz, method);

        this.collectionType = extDirectMethodAnnotation.entryClass() == Object.class ? null
                : extDirectMethodAnnotation.entryClass();

        if (this.collectionType == null) {
            for (ParameterInfo parameter : this.parameters) {
                Class<?> collType = parameter.getCollectionType();
                if (collType != null) {
                    this.collectionType = collType;
                    break;
                }
            }
        }
    } else {
        if (method.getReturnType().equals(Void.TYPE)) {

            RequestMapping methodAnnotation = AnnotationUtils.findAnnotation(method, RequestMapping.class);
            RequestMapping classAnnotation = AnnotationUtils.findAnnotation(clazz, RequestMapping.class);

            String path = null;
            if (hasValue(classAnnotation)) {
                path = classAnnotation.value()[0];
            }

            if (hasValue(methodAnnotation)) {
                String methodPath = methodAnnotation.value()[0];
                if (path != null) {
                    path = path + methodPath;
                } else {
                    path = methodPath;
                }
            }

            if (path != null) {
                if (path.charAt(0) == '/' && path.length() > 1) {
                    path = path.substring(1, path.length());
                }
                this.forwardPath = "forward:" + path;
            }
        } else {
            this.handlerMethod = new HandlerMethod(beanName, context, method).createWithResolvedBean();
        }
    }

    switch (this.type) {
    case SIMPLE:
        int paramLength = 0;
        for (ParameterInfo parameter : this.parameters) {
            if (parameter.isClientParameter()) {
                paramLength++;
            }
        }
        this.action = Action.create(method.getName(), paramLength, extDirectMethodAnnotation.batched());
        break;
    case SIMPLE_NAMED:
        int noOfClientParameters = 0;
        Class<?> parameterType = null;

        List<String> parameterNames = new ArrayList<String>();
        for (ParameterInfo parameter : this.parameters) {
            if (parameter.isClientParameter()) {
                noOfClientParameters++;
                parameterType = parameter.getType();
                parameterNames.add(parameter.getName());
            }
        }

        if (noOfClientParameters == 1 && Map.class.isAssignableFrom(parameterType)) {
            this.action = Action.createNamed(method.getName(), Collections.<String>emptyList(), Boolean.FALSE,
                    extDirectMethodAnnotation.batched());
        } else {
            this.action = Action.createNamed(method.getName(), Collections.unmodifiableList(parameterNames),
                    null, extDirectMethodAnnotation.batched());
        }
        break;
    case FORM_LOAD:
        this.action = Action.create(method.getName(), 1, extDirectMethodAnnotation.batched());
        break;
    case STORE_READ:
    case STORE_MODIFY:
    case TREE_LOAD:
        List<String> metadataParams = new ArrayList<String>();
        for (ParameterInfo parameter : this.parameters) {
            if (parameter.hasMetadataParamAnnotation()) {
                metadataParams.add(parameter.getName());
            }
        }
        this.action = Action.createTreeLoad(method.getName(), 1, metadataParams,
                extDirectMethodAnnotation.batched());
        break;
    case FORM_POST:
        this.action = Action.createFormHandler(method.getName(), 0);
        break;
    case FORM_POST_JSON:
        this.action = Action.create(method.getName(), 1, extDirectMethodAnnotation.batched());
        break;
    case POLL:
        this.pollingProvider = new PollingProvider(beanName, method.getName(),
                extDirectMethodAnnotation.event());
        break;
    default:
        throw new IllegalStateException("ExtDirectMethodType: " + this.type + " does not exists");
    }

    this.action = extractDocumentationAnnotations(extDirectMethodAnnotation.documentation());

}

From source file:com.socialize.SocializeActionProxy.java

protected boolean isVoidMethod(Method method) {
    Class<?> returnType = method.getReturnType();
    return (returnType == null || returnType.equals(Void.TYPE));
}

From source file:org.diorite.impl.bean.BeanScanner.java

private void processClass(final Class<?> clazz) throws BeanException {
    // Bean registration by class
    if (clazz.isAnnotationPresent(DioriteBean.class)) {
        final DioriteBean beanInfo = clazz.getAnnotation(DioriteBean.class);
        final BeanContainer beanContainer = new BeanContainer(clazz, new ClassBeanProvider(clazz));

        this.beanManager.registerBean(beanContainer);
    }//from  w w  w .ja v  a2s  . c o m

    // Bean registration by constructor
    for (final Constructor<?> constructor : clazz.getConstructors()) {
        if (constructor.isAnnotationPresent(DioriteBean.class)) {
            final DioriteBean beanInfo = constructor.getAnnotation(DioriteBean.class);
            final BeanContainer beanContainer = new BeanContainer(clazz,
                    new ConstructorBeanProvider(constructor));

            this.beanManager.registerBean(beanContainer);
        }
    }

    // Bean registration by method
    for (final Method method : clazz.getMethods()) {
        if (method.isAnnotationPresent(DioriteBean.class)) {
            final Class<?> returnType = method.getReturnType();
            if (returnType.equals(Void.TYPE) || returnType.isPrimitive()) {
                throw new BeanRegisteringException(MessageFormat.format(
                        "Can't register method '{0}' in class '{1}' as Diorite Bean. Method must return object.",
                        method.getName(), clazz.getName()));
            } else if (returnType.getPackage().equals(JAVA_PACKAGE)) {
                throw new BeanRegisteringException(MessageFormat.format(
                        "Can't register method '{0}' in class '{1}' as Diorite Bean. Method can't return object from java package.",
                        method.getName(), clazz.getName()));
            }
            final DioriteBean beanInfo = method.getAnnotation(DioriteBean.class);

            final BeanContainer beanContainer = new BeanContainer(returnType, new MethodBeanProvider(method));
            this.beanManager.registerBean(beanContainer);
        }
    }

    for (final Field field : clazz.getDeclaredFields()) {
        if (field.isAnnotationPresent(InjectedValue.class)) {
            this.beanManager.addInjectorCode(clazz);
            break;
        }
    }
}