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:ninja.eivind.hotsreplayuploader.ClientTest.java

@Test
public void testClientIsMainClass() throws Exception {
    String className = parse.select("project > properties > mainClass").text();

    LOG.info("Loading class " + className);
    Class<?> mainClass = Class.forName(className);

    Method main = mainClass.getDeclaredMethod("main", String[].class);
    int modifiers = main.getModifiers();

    Class<?> returnType = main.getReturnType();

    assertEquals("Client is mainClass", Client.class, mainClass);
    assertSame("Main method returns void", returnType, Void.TYPE);
    assertTrue("Main method is static", Modifier.isStatic(modifiers));
    assertTrue("Main method is public", Modifier.isPublic(modifiers));
}

From source file:Utils.java

/**
 * Returns true if the method is a JMX attribute setter method
 *///from  w w  w .j av a2  s.c o m
public static boolean isAttributeSetter(Method m) {
    if (m == null)
        return false;

    String name = m.getName();
    Class retType = m.getReturnType();
    Class[] params = m.getParameterTypes();
    if (retType == Void.TYPE && params.length == 1 && name.startsWith("set") && name.length() > 3) {
        return true;
    }
    return false;
}

From source file:mangotiger.poker.channel.EventChannelImpl.java

static boolean methodMatchesEvent(final Method method, final Class<?> event) {
    return METHOD_NAME.equals(method.getName()) && Modifier.isPublic(method.getModifiers())
            && Void.TYPE.equals(method.getReturnType()) && method.getParameterTypes().length == 1
            && method.getParameterTypes()[0].isAssignableFrom(event);
}

From source file:org.jasig.ssp.service.impl.MapStatusReportCalcTaskImpl.java

public Class<Void> getBatchExecReturnType() {
    return Void.TYPE;
}

From source file:com.monarchapis.client.resource.AbstractResource.java

@SuppressWarnings("unchecked")
protected static <T> T parseAs(String response, Class<T> clazz) {
    try {//from  w w w  .j  a va 2  s . c  om
        if (clazz == Void.class) {
            return (T) Void.TYPE;
        }

        return MAPPER.readValue(response, clazz);
    } catch (Exception e) {
        throw new RestException(e);
    }
}

From source file:org.gradle.runtime.base.internal.registry.AbstractAnnotationModelRuleDefinitionHandler.java

protected Class<? extends T> readType(MethodRuleDefinition ruleDefinition) {
    if (!ModelType.of(Void.TYPE).equals(ruleDefinition.getReturnType())) {
        throw new InvalidComponentModelException(
                String.format("%s method must not have a return value.", annotationClass.getSimpleName()));
    }//w ww .j a v  a2  s .  c o  m
    if (ruleDefinition.getReferences().size() != 1) {
        throw new InvalidComponentModelException(
                String.format("%s method must have a single parameter of type '%s'.",
                        annotationClass.getSimpleName(), builderInterface.toString()));
    }
    ModelType<?> builder = ruleDefinition.getReferences().get(0).getType();
    if (!builderInterface.isAssignableFrom(builder)) {
        throw new InvalidComponentModelException(
                String.format("%s method must have a single parameter of type '%s'.",
                        annotationClass.getSimpleName(), builderInterface.toString()));
    }
    if (builder.getTypeVariables().size() != 1) {
        throw new InvalidComponentModelException(String
                .format("Parameter of type '%s' must declare a type parameter.", builderInterface.toString()));
    }
    ModelType<?> subType = builder.getTypeVariables().get(0);
    if (!baseInterface.isAssignableFrom(subType) || subType.isAssignableFrom(baseInterface)) {
        throw new InvalidComponentModelException(
                String.format("%s type '%s' is not a concrete subtype of '%s'.",
                        StringUtils.capitalize(modelName), subType.toString(), baseInterface.toString()));
    }
    // TODO:DAZ Propogate ModelType out
    return (Class<? extends T>) subType.getRawClass();
}

From source file:com.teletalk.jserver.util.aop.MethodInvocationDebugLogger.java

/**
 *///from   w ww  .  j a v  a 2  s.  c  o  m
public Object invoke(final MethodInvocation methodInvocation) throws Throwable {
    Method method = methodInvocation.getMethod();
    String paramLogString = null;
    long executionStartTime = System.currentTimeMillis();
    Log logger = this.logger;
    String methodName;
    if (logger == null) {
        logger = LogFactory.getLog(method.getDeclaringClass());
        methodName = method.getName();
    } else
        methodName = method.getDeclaringClass().getName() + "." + method.getName();

    if (logger.isDebugEnabled()) {
        paramLogString = "";
        Object[] arguments = methodInvocation.getArguments();
        if (arguments != null) {
            for (int i = 0; i < arguments.length; i++) {
                paramLogString += StringUtils.limitStringLength(StringUtils.toString(arguments[i]),
                        this.maxParameterStringRepresentationLength);
                if (i < (arguments.length - 1))
                    paramLogString += ", ";
            }
        }

        logger.debug("Executing " + methodName + "(" + paramLogString + ").");
    }

    Object returnValue = methodInvocation.proceed();

    if (logger.isDebugEnabled()) {
        if ((method.getReturnType() == null) || method.getReturnType().equals(Void.TYPE)) {
            logger.debug("Done executing " + methodName + "(" + paramLogString + ") after "
                    + (System.currentTimeMillis() - executionStartTime) + "ms.");
        } else {
            logger.debug("Done executing " + methodName + "(" + paramLogString + ") after "
                    + (System.currentTimeMillis() - executionStartTime) + "ms" + " - return value: "
                    + StringUtils.limitStringLength(StringUtils.toString(returnValue),
                            this.maxReturnValueStringRepresentationLength)
                    + ".");
        }
    }

    return returnValue;
}

From source file:org.jsonschema2pojo.integration.MediaIT.java

@Test
public void shouldCreateByteArraySetter() throws SecurityException, NoSuchMethodException {
    Method setter = classWithMediaProperties.getDeclaredMethod("setMinimalBinary", BYTE_ARRAY);

    assertThat("the minimal binary setter has return type void", setter.getReturnType(),
            equalToType(Void.TYPE));
}

From source file:org.nuxeo.ecm.automation.core.impl.InvokableMethod.java

public InvokableMethod(OperationType op, Method method) {
    produce = method.getReturnType();/*from w w w .  j a  v a2s .c  o m*/
    Class<?>[] p = method.getParameterTypes();
    if (p.length > 1) {
        throw new IllegalArgumentException("Operation method must accept at most one argument: " + method);
    }
    this.op = op;
    this.method = method;
    if (priority > 0) {
        priority += USER_PRIORITY;
    }
    String inputType = this.op.getInputType();
    if (inputType != null) {
        switch (inputType) {
        case "document":
            consume = DocumentModel.class;
            break;
        case "documents":
            consume = DocumentModelList.class;
            break;
        case "blob":
            consume = Blob.class;
            break;
        case "blobs":
            consume = Blobs.class;
            break;
        default:
            consume = Object.class;
            break;
        }
    } else {
        consume = p.length == 0 ? Void.TYPE : p[0];
    }
}

From source file:org.grouplens.grapht.util.ClassProxy.java

/**
 * Resolve a class proxy to a class./*from   w w  w. j a v  a2  s . c o  m*/
 * @return The class represented by this proxy.
 * @throws ClassNotFoundException if the class represented by this proxy cannot be found.
 */
public Class<?> resolve() throws ClassNotFoundException {
    WeakReference<Class<?>> ref = theClass;
    Class<?> cls = ref == null ? null : ref.get();
    if (cls == null) {
        if (className.equals("void")) {
            // special case
            cls = Void.TYPE;
        } else {
            cls = ClassUtils.getClass(classLoader, className);
        }
        long check = checksumClass(cls);
        if (!isSerializationPermissive() && checksum != check) {
            throw new ClassNotFoundException("checksum mismatch for " + cls.getName());
        } else {
            if (checksum != check) {
                logger.warn("checksum mismatch for {}", cls);
            }
            theClass = new WeakReference<Class<?>>(cls);
        }
    }
    return cls;
}