Example usage for java.lang Boolean TYPE

List of usage examples for java.lang Boolean TYPE

Introduction

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

Prototype

Class TYPE

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

Click Source Link

Document

The Class object representing the primitive type boolean.

Usage

From source file:com.useekm.indexing.internal.BigdataEvaluationStrategy.java

@SuppressWarnings({ "rawtypes", "unchecked" })
private static Method getStreamingEvaluate() {
    try {// ww  w  .j a v  a 2  s  . c o  m
        Class connectionClass = Class.forName("com.bigdata.rdf.sail.BigdataSail$BigdataSailConnection");
        return connectionClass.getMethod("evaluate", TupleExpr.class, Dataset.class, BindingSet.class,
                CloseableIteration.class, Boolean.TYPE, Properties.class);
    } catch (ClassNotFoundException e) {
        LOG.warn("Could not initialize BigdataEvaluationStrategy properly. Bigdata is not on the classpath.",
                e);
    } catch (SecurityException e) {
        LOG.warn("Could not initialize BigdataEvaluationStrategy properly. Bigdata.evaluate is secured", e);
    } catch (NoSuchMethodException e) {
        LOG.warn("Could not initialize BigdataEvaluationStrategy properly. Bigdata.evaluate does not exist", e);
    }
    return null;
}

From source file:org.pentaho.ui.xul.impl.AbstractXulDomContainer.java

private Class unBoxPrimative(Class clazz) {
    if (clazz == Boolean.class) {
        return Boolean.TYPE;
    } else if (clazz == Integer.class) {
        return Integer.TYPE;
    } else if (clazz == Float.class) {
        return Float.TYPE;
    } else if (clazz == Double.class) {
        return Double.TYPE;
    } else if (clazz == Short.class) {
        return Short.TYPE;
    } else if (clazz == Long.class) {
        return Long.TYPE;
    } else {/*w  ww  .ja  v a2 s.  co  m*/
        return clazz;
    }
}

From source file:com.boylesoftware.web.impl.UserInputControllerMethodArgHandler.java

/**
 * Create new handler./*from ww  w.ja  v  a 2  s  .  c o  m*/
 *
 * @param validatorFactory Validator factory.
 * @param beanClass User input bean class.
 * @param validationGroups Validation groups to apply during bean
 * validation, or empty array to use the default group.
 *
 * @throws UnavailableException If an error happens.
 */
UserInputControllerMethodArgHandler(final ValidatorFactory validatorFactory, final Class<?> beanClass,
        final Class<?>[] validationGroups) throws UnavailableException {

    this.validatorFactory = validatorFactory;

    this.beanClass = beanClass;
    this.validationGroups = validationGroups;

    try {
        final BeanInfo beanInfo = Introspector.getBeanInfo(this.beanClass);
        final PropertyDescriptor[] propDescs = beanInfo.getPropertyDescriptors();
        final List<FieldDesc> beanFields = new ArrayList<>();
        for (final PropertyDescriptor propDesc : propDescs) {
            final String propName = propDesc.getName();
            final Class<?> propType = propDesc.getPropertyType();
            final Method propGetter = propDesc.getReadMethod();
            final Method propSetter = propDesc.getWriteMethod();

            if ((propGetter == null) || (propSetter == null))
                continue;

            Field propField = null;
            for (Class<?> c = this.beanClass; !c.equals(Object.class); c = c.getSuperclass()) {
                try {
                    propField = c.getDeclaredField(propName);
                    break;
                } catch (final NoSuchFieldException e) {
                    // nothing, continue the loop
                }
            }
            final boolean noTrim = (((propField != null) && propField.isAnnotationPresent(NoTrim.class))
                    || (propGetter.isAnnotationPresent(NoTrim.class)));

            Class<? extends Binder> binderClass = null;
            String format = null;
            String errorMessage = Bind.DEFAULT_MESSAGE;
            Bind bindAnno = null;
            if (propField != null)
                bindAnno = propField.getAnnotation(Bind.class);
            if (bindAnno == null)
                bindAnno = propGetter.getAnnotation(Bind.class);
            if (bindAnno != null) {
                binderClass = bindAnno.binder();
                format = bindAnno.format();
                errorMessage = bindAnno.message();
            }
            if (binderClass == null) {
                if ((String.class).isAssignableFrom(propType))
                    binderClass = StringBinder.class;
                else if ((Boolean.class).isAssignableFrom(propType) || propType.equals(Boolean.TYPE))
                    binderClass = BooleanBinder.class;
                else if ((Integer.class).isAssignableFrom(propType) || propType.equals(Integer.TYPE))
                    binderClass = IntegerBinder.class;
                else if (propType.isEnum())
                    binderClass = EnumBinder.class;
                else // TODO: add more standard binders
                    throw new UnavailableException(
                            "Unsupported user input bean field type " + propType.getName() + ".");
            }

            beanFields.add(new FieldDesc(propDesc, noTrim, binderClass.newInstance(), format, errorMessage));
        }
        this.beanFields = beanFields.toArray(new FieldDesc[beanFields.size()]);
    } catch (final IntrospectionException e) {
        this.log.error("error introspecting user input bean", e);
        throw new UnavailableException("Specified user input bean" + " class could not be introspected.");
    } catch (final IllegalAccessException | InstantiationException e) {
        this.log.error("error instatiating binder", e);
        throw new UnavailableException("Used user input bean field binder" + " could not be instantiated.");
    }

    this.beanPool = new FastPool<>(new PoolableObjectFactory<PoolableUserInput>() {

        @Override
        public PoolableUserInput makeNew(final FastPool<PoolableUserInput> pool, final int pooledObjectId) {

            try {
                return new PoolableUserInput(pool, pooledObjectId, beanClass.newInstance());
            } catch (final InstantiationException | IllegalAccessException e) {
                throw new RuntimeException("Error instatiating user input bean.", e);
            }
        }
    }, "UserInputBeansPool_" + beanClass.getSimpleName());
}

From source file:fragment.web.UsersControllerTest.java

@SuppressWarnings({ "rawtypes" })
@Test//from   w w  w .ja  v a 2  s . com
public void testRouting() throws Exception {
    logger.debug("Testing routing....");
    DispatcherTestServlet servlet = this.getServletInstance();
    Class controllerClass = controller.getClass();
    Method expected = locateMethod(controllerClass, "listUsersForAccount",
            new Class[] { Tenant.class, Boolean.TYPE, String.class, ModelMap.class, HttpSession.class,
                    String.class, int.class, int.class, String.class, HttpServletRequest.class });

    Method handler = servlet.recognize(getRequestTemplate(HttpMethod.GET, "/users"));
    Assert.assertEquals(expected, handler);

    handler = servlet.recognize(getRequestTemplate(HttpMethod.GET, "/users/"));
    Assert.assertEquals(expected, handler);

    expected = locateMethod(controllerClass, "show", new Class[] { String.class, ModelMap.class });
    handler = servlet.recognize(getRequestTemplate(HttpMethod.GET, "/users/1"));
    Assert.assertEquals(expected, handler);

    expected = locateMethod(controllerClass, "createStepOne", new Class[] { Tenant.class, String.class,
            ModelMap.class, HttpSession.class, HttpServletRequest.class });
    handler = servlet.recognize(getRequestTemplate(HttpMethod.GET, "/users/new/step1"));
    Assert.assertEquals(expected, handler);

    expected = locateMethod(controllerClass, "login",
            new Class[] { Tenant.class, String.class, String.class, String.class, ModelMap.class });
    handler = servlet.recognize(getRequestTemplate(HttpMethod.GET, "/users/cloud_login"));
    Assert.assertEquals(expected, handler);

}

From source file:org.apache.struts.action.TestDynaActionForm.java

/**
 * Positive getDynaProperty on property <code>booleanSecond</code> that
 * uses an "is" method as the getter./* w  w w . ja  v a  2  s  .c  om*/
 */
public void testGetDescriptorSecond() {
    testGetDescriptorBase("booleanSecond", Boolean.TYPE);
}

From source file:de.ma.it.common.sm.transition.MethodTransition.java

private boolean match(Class<?> paramType, Object arg, Class<?> argType) {
    if (paramType.isPrimitive()) {
        if (paramType.equals(Boolean.TYPE)) {
            return arg instanceof Boolean;
        }/*from w w w .j ava  2 s . co  m*/
        if (paramType.equals(Integer.TYPE)) {
            return arg instanceof Integer;
        }
        if (paramType.equals(Long.TYPE)) {
            return arg instanceof Long;
        }
        if (paramType.equals(Short.TYPE)) {
            return arg instanceof Short;
        }
        if (paramType.equals(Byte.TYPE)) {
            return arg instanceof Byte;
        }
        if (paramType.equals(Double.TYPE)) {
            return arg instanceof Double;
        }
        if (paramType.equals(Float.TYPE)) {
            return arg instanceof Float;
        }
        if (paramType.equals(Character.TYPE)) {
            return arg instanceof Character;
        }
    }
    return argType.isAssignableFrom(paramType) && paramType.isAssignableFrom(arg.getClass());
}

From source file:com.netspective.commons.lang.ValueBeanGeneratorClassLoader.java

/**
 * Convert runtime java.lang.Class to BCEL Type object.
 *
 * @param cl Java class/*from   w ww  . j  a  v a 2s  . c om*/
 *
 * @return corresponding Type object
 */
public static Type getBCELType(java.lang.Class cl) {
    if (cl == null) {
        throw new IllegalArgumentException("Class must not be null");
    }

    /* That's an amzingly easy case, because getName() returns
     * the signature. That's what we would have liked anyway.
     */
    if (cl.isArray()) {
        return Type.getType(cl.getName());
    } else if (cl.isPrimitive()) {
        if (cl == Integer.TYPE) {
            return Type.INT;
        } else if (cl == Void.TYPE) {
            return Type.VOID;
        } else if (cl == Double.TYPE) {
            return Type.DOUBLE;
        } else if (cl == Float.TYPE) {
            return Type.FLOAT;
        } else if (cl == Boolean.TYPE) {
            return Type.BOOLEAN;
        } else if (cl == Byte.TYPE) {
            return Type.BYTE;
        } else if (cl == Short.TYPE) {
            return Type.SHORT;
        } else if (cl == Long.TYPE) {
            return Type.LONG;
        } else if (cl == Character.TYPE) {
            return Type.CHAR;
        } else {
            throw new IllegalStateException("Ooops, what primitive type is " + cl);
        }
    } else { // "Real" class
        return new ObjectType(cl.getName());
    }
}

From source file:com.ryan.ryanreader.jsonwrap.JsonBufferedObject.java

public void populateObject(final Object o) throws InterruptedException, IOException, IllegalArgumentException,
        InstantiationException, NoSuchMethodException, InvocationTargetException {

    if (join() != Status.LOADED) {
        throwFailReasonException();/*from www. ja  v  a2s  .  com*/
    }

    final Field[] objectFields = o.getClass().getFields();

    try {

        for (final Field objectField : objectFields) {

            if ((objectField.getModifiers() & Modifier.TRANSIENT) != 0) {
                continue;
            }

            final JsonValue val;

            if (properties.containsKey(objectField.getName())) {
                val = properties.get(objectField.getName());

            } else if (objectField.getName().startsWith("_json_")) {
                val = properties.get(objectField.getName().substring("_json_".length()));
            } else {
                val = null;
            }

            if (val == null) {
                continue;
            }

            objectField.setAccessible(true);

            final Class<?> fieldType = objectField.getType();

            if (fieldType == Long.class || fieldType == Long.TYPE) {
                objectField.set(o, val.asLong());

            } else if (fieldType == Double.class || fieldType == Double.TYPE) {
                objectField.set(o, val.asDouble());

            } else if (fieldType == Integer.class || fieldType == Integer.TYPE) {
                objectField.set(o, val.isNull() ? null : val.asLong().intValue());

            } else if (fieldType == Float.class || fieldType == Float.TYPE) {
                objectField.set(o, val.isNull() ? null : val.asDouble().floatValue());

            } else if (fieldType == Boolean.class || fieldType == Boolean.TYPE) {
                objectField.set(o, val.asBoolean());

            } else if (fieldType == String.class) {
                objectField.set(o, val.asString());

            } else if (fieldType == JsonBufferedArray.class) {
                objectField.set(o, val.asArray());

            } else if (fieldType == JsonBufferedObject.class) {
                objectField.set(o, val.asObject());

            } else if (fieldType == JsonValue.class) {
                objectField.set(o, val);

            } else if (fieldType == Object.class) {

                final Object result;

                switch (val.getType()) {
                case BOOLEAN:
                    result = val.asBoolean();
                    break;
                case INTEGER:
                    result = val.asLong();
                    break;
                case STRING:
                    result = val.asString();
                    break;
                case FLOAT:
                    result = val.asDouble();
                    break;
                default:
                    result = val;
                }

                objectField.set(o, result);

            } else {
                objectField.set(o, val.asObject(fieldType));
            }
        }

    } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
    }
}

From source file:net.sourceforge.pmd.typeresolution.ClassTypeResolverTest.java

@Test
public void testLiterals() throws JaxenException {
    ASTCompilationUnit acu = parseAndTypeResolveForClass15(Literals.class);
    List<ASTLiteral> literals = convertList(acu.findChildNodesWithXPath("//Literal"), ASTLiteral.class);
    int index = 0;

    // String s = "s";
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(String.class, literals.get(index++).getType());

    // boolean boolean1 = false;
    assertEquals(Boolean.TYPE, literals.get(index).getFirstDescendantOfType(ASTBooleanLiteral.class).getType());
    assertEquals(Boolean.TYPE, literals.get(index++).getType());

    // boolean boolean2 = true;
    assertEquals(Boolean.TYPE, literals.get(index).getFirstDescendantOfType(ASTBooleanLiteral.class).getType());
    assertEquals(Boolean.TYPE, literals.get(index++).getType());

    // Object obj = null;
    assertNull(literals.get(index).getFirstDescendantOfType(ASTNullLiteral.class).getType());
    assertNull(literals.get(index++).getType());

    // byte byte1 = 0;
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Integer.TYPE, literals.get(index++).getType());

    // byte byte2 = 0x0F;
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Integer.TYPE, literals.get(index++).getType());

    // byte byte3 = -007;
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Integer.TYPE, literals.get(index++).getType());

    // short short1 = 0;
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Integer.TYPE, literals.get(index++).getType());

    // short short2 = 0x0F;
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Integer.TYPE, literals.get(index++).getType());

    // short short3 = -007;
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Integer.TYPE, literals.get(index++).getType());

    // char char1 = 0;
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Integer.TYPE, literals.get(index++).getType());

    // char char2 = 0x0F;
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Integer.TYPE, literals.get(index++).getType());

    // char char3 = 007;
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Integer.TYPE, literals.get(index++).getType());

    // char char4 = 'a';
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Character.TYPE, literals.get(index++).getType());

    // int int1 = 0;
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Integer.TYPE, literals.get(index++).getType());

    // int int2 = 0x0F;
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Integer.TYPE, literals.get(index++).getType());

    // int int3 = -007;
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Integer.TYPE, literals.get(index++).getType());

    // int int4 = 'a';
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Character.TYPE, literals.get(index++).getType());

    // long long1 = 0;
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Integer.TYPE, literals.get(index++).getType());

    // long long2 = 0x0F;
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Integer.TYPE, literals.get(index++).getType());

    // long long3 = -007;
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Integer.TYPE, literals.get(index++).getType());

    // long long4 = 0L;
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Long.TYPE, literals.get(index++).getType());

    // long long5 = 0x0Fl;
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Long.TYPE, literals.get(index++).getType());

    // long long6 = -007L;
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Long.TYPE, literals.get(index++).getType());

    // long long7 = 'a';
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Character.TYPE, literals.get(index++).getType());

    // float float1 = 0.0f;
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Float.TYPE, literals.get(index++).getType());

    // float float2 = -10e+01f;
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Float.TYPE, literals.get(index++).getType());

    // float float3 = 0x08.08p3f;
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Float.TYPE, literals.get(index++).getType());

    // float float4 = 0xFF;
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Integer.TYPE, literals.get(index++).getType());

    // float float5 = 'a';
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Character.TYPE, literals.get(index++).getType());

    // double double1 = 0.0;
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Double.TYPE, literals.get(index++).getType());

    // double double2 = -10e+01;
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Double.TYPE, literals.get(index++).getType());

    // double double3 = 0x08.08p3;
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Double.TYPE, literals.get(index++).getType());

    // double double4 = 0xFF;
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Integer.TYPE, literals.get(index++).getType());

    // double double5 = 'a';
    assertEquals(0, literals.get(index).jjtGetNumChildren());
    assertEquals(Character.TYPE, literals.get(index++).getType());

    // Make sure we got them all.
    assertEquals("All literals not tested", index, literals.size());
}

From source file:com.aol.one.patch.DefaultPatcher.java

private List<MethodData> generateMethodData(List<String> methodNames, JsonNode valueNode) {

    List<MethodData> dataList = new ArrayList<>();
    if (valueNode.isTextual()) {
        for (String methodName : methodNames) {
            dataList.add(new MethodData(methodName, String.class, valueNode.asText()));
        }//from w ww.  j  a v a2s  .  c o  m
    } else if (valueNode.isNumber()) {
        for (String methodName : methodNames) {
            if (valueNode.isIntegralNumber()) {
                dataList.add(new MethodData(methodName, Long.TYPE, valueNode.asLong()));
                dataList.add(new MethodData(methodName, Long.class, valueNode.asLong()));
                dataList.add(new MethodData(methodName, Integer.TYPE, valueNode.asInt()));
                dataList.add(new MethodData(methodName, Integer.class, valueNode.asInt()));
                dataList.add(new MethodData(methodName, Short.TYPE, (short) valueNode.asInt()));
                dataList.add(new MethodData(methodName, Short.class, (short) valueNode.asInt()));
            } else {
                dataList.add(new MethodData(methodName, Double.TYPE, valueNode.asDouble()));
                dataList.add(new MethodData(methodName, Double.class, valueNode.asDouble()));
                dataList.add(new MethodData(methodName, Float.TYPE, valueNode.asDouble()));
                dataList.add(new MethodData(methodName, Float.class, valueNode.asDouble()));
            }
        }
    } else if (valueNode.isBoolean()) {
        for (String methodName : methodNames) {
            dataList.add(new MethodData(methodName, Boolean.TYPE, valueNode.asBoolean()));
            dataList.add(new MethodData(methodName, Boolean.class, valueNode.asBoolean()));
        }

    }

    // default
    for (String methodName : methodNames) {
        dataList.add(new MethodData(methodName, JsonNode.class, valueNode));
    }

    return dataList;
}