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:org.bonitasoft.engine.bdm.CodeGenerator.java

public JMethod addSetter(final JDefinedClass definedClass, final JFieldVar field) {
    final JMethod method = definedClass.method(JMod.PUBLIC, Void.TYPE, getSetterName(field));
    method.param(field.type(), field.name());
    method.body().assign(JExpr._this().ref(field.name()), JExpr.ref(field.name()));
    return method;
}

From source file:org.tdar.core.service.ReflectionService.java

/**
 * Based on the field and the object passed in, call the getter and return the result
 * //ww  w .  j  ava 2 s  . com
 * @param obj
 * @param field
 * @return
 */
@SuppressWarnings("unchecked")
public <T> T callFieldGetter(Object obj, Field field) {
    // logger.debug("calling getter on: {} {} ", obj, field.getName());
    logger.trace("{}", field.getDeclaringClass());
    Method method = ReflectionUtils.findMethod(field.getDeclaringClass(), generateGetterName(field));
    if (method.getReturnType() != Void.TYPE) {
        try {
            return (T) method.invoke(obj);
        } catch (Exception e) {
            logger.debug("cannot call field getter for field: {}", field, e);
        }
    }
    return null;
}

From source file:org.mashti.jetson.util.JsonParserUtil.java

/**
 * Reads a field value as the provided type.
 *
 * @param <Value> the value type/*  ww  w .j  av a  2 s.c  o  m*/
 * @param parser the parser
 * @param expected_type the expected type of the value
 * @return the value
 * @throws IOException Signals that an I/O exception has occurred.
 */
public static <Value> Value readValueAs(final JsonParser parser, final Class<Value> expected_type)
        throws IOException {

    final Value value;
    if (expected_type.equals(Void.TYPE)) {
        expectNullValue(parser);
        value = null;
    } else {
        parser.nextToken();
        value = parser.readValueAs(expected_type);
    }
    return value;
}

From source file:org.gradle.api.internal.project.AnnotationProcessingTaskFactory.java

private boolean isGetter(Method method) {
    return method.getName().startsWith("get") && method.getReturnType() != Void.TYPE
            && method.getParameterTypes().length == 0 && !Modifier.isStatic(method.getModifiers());
}

From source file:org.renjin.invoke.model.JvmMethod.java

public boolean returnsVoid() {
    return method.getReturnType() == Void.class || method.getReturnType() == Void.TYPE;
}

From source file:org.springframework.cloud.stream.binder.kafka.streams.KafkaStreamsStreamListenerSetupMethodOrchestrator.java

@Override
public boolean supports(Method method) {
    return methodParameterSupports(method)
            && (methodReturnTypeSuppports(method) || Void.TYPE.equals(method.getReturnType()));
}

From source file:org.batoo.jpa.jdbc.dbutils.QueryRunner.java

/**
 * Fill the <code>PreparedStatement</code> replacement parameters with the given objects.
 * //www  .ja  va2s  .c om
 * @param statement
 *            PreparedStatement to fill
 * @param params
 *            Query replacement parameters; <code>null</code> is a valid value to pass in.
 * @throws SQLException
 *             if a database access error occurs
 */
private void fillStatement(PreparedStatement statement, Object... params) throws SQLException {
    // use local variable for performance
    boolean pmdKnownBroken = this.pmdKnownBroken;
    ParameterMetaData pmd = this.pmd;
    final boolean hasLob = this.hasLob;

    if (pmdKnownBroken) {
        ((PreparedStatementProxy) statement).setParamCount(params.length);
    } else {
        ((PreparedStatementProxy) statement).setParamCount(-1);
    }

    // if the jdbc adaptor wants to modify the parameters we let it do it its own way
    final JdbcAdaptor jdbcAdaptor = this.jdbcAdaptor;
    if ((jdbcAdaptor != null) && jdbcAdaptor.modifiesParameters()) {
        pmd = this.pmd = statement.getParameterMetaData();

        jdbcAdaptor.modifyParameters(pmd, params);
    }

    for (int i = 0; i < params.length; i++) {
        final Object param = params[i];
        if ((param != null) && (param != Void.TYPE)) {
            if (hasLob && (param instanceof Clob)) {
                if (this.jdbcAdaptor instanceof OracleAdaptor) {
                    statement.setCharacterStream(i + 1, ((Clob) param).getCharacterStream());
                } else {
                    statement.setClob(i + 1, (Clob) param);
                }
            } else if (hasLob && (param instanceof Blob)) {
                if (this.jdbcAdaptor instanceof OracleAdaptor) {
                    statement.setBinaryStream(i + 1, ((Blob) param).getBinaryStream());
                } else {
                    statement.setBlob(i + 1, (Blob) param);
                }
            } else {
                statement.setObject(i + 1, param);
            }
        } else {
            if (!pmdKnownBroken && (pmd == null)) {
                pmd = this.pmd = statement.getParameterMetaData();
            }

            // VARCHAR works with many drivers regardless of the actual column type.
            // Oddly, NULL and OTHER don't work with Oracle's drivers.
            int sqlType = Types.VARCHAR;
            if (!pmdKnownBroken) {
                try {
                    sqlType = pmd.getParameterType(i + 1);
                } catch (final SQLException e) {
                    pmdKnownBroken = this.pmdKnownBroken = true;
                }
            }
            if (param != Void.TYPE) {
                statement.setNull(i + 1, sqlType);
            }
        }
    }
}

From source file:com.haulmont.cuba.web.gui.components.table.LinkCellClickListener.java

protected Method findLinkInvokeMethod(Class cls, String methodName) {
    Method exactMethod = MethodUtils.getAccessibleMethod(cls, methodName,
            new Class[] { Entity.class, String.class });
    if (exactMethod != null) {
        return exactMethod;
    }// w ww  .  j av a2s.com

    // search through all methods
    Method[] methods = cls.getMethods();
    for (Method availableMethod : methods) {
        if (availableMethod.getName().equals(methodName)) {
            if (availableMethod.getParameterCount() == 2 && Void.TYPE.equals(availableMethod.getReturnType())) {
                if (Entity.class.isAssignableFrom(availableMethod.getParameterTypes()[0])
                        && String.class == availableMethod.getParameterTypes()[1]) {
                    // get accessible version of method
                    return MethodUtils.getAccessibleMethod(availableMethod);
                }
            }
        }
    }
    return null;
}

From source file:org.bonitasoft.engine.bdm.CodeGenerator.java

public JMethod addListSetter(final JDefinedClass definedClass, final JFieldVar field) {
    final JMethod method = definedClass.method(JMod.PUBLIC, Void.TYPE, getSetterName(field));
    method.param(field.type(), field.name());
    final JFieldRef thisField = JExpr._this().ref(field.name());
    final JConditional ifListIsNull = method.body()._if(thisField.eq(JExpr._null()));

    ifListIsNull._then().assign(JExpr._this().ref(field.name()), JExpr.ref(field.name()));

    final JBlock elseBlock = ifListIsNull._else();
    elseBlock.invoke(JExpr._this().ref(field.name()), "clear");
    elseBlock.invoke(JExpr._this().ref(field.name()), "addAll").arg(field);

    return method;
}

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

@Test
public void testResultNull() {
    Map<String, Object> params = new LinkedHashMap<String, Object>();
    params.put("userName", "martin");
    ControllerUtil.sendAndReceiveNamed(mockMvc, "remoteProviderSimpleNamed", "method3", Void.TYPE, params);
}