Example usage for java.lang Float TYPE

List of usage examples for java.lang Float TYPE

Introduction

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

Prototype

Class TYPE

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

Click Source Link

Document

The Class instance representing the primitive type float .

Usage

From source file:org.seasar.struts.lessconfig.factory.AbstractValidatorAnnotationHandler.java

protected String getAutoTypeValidatorName(PropertyDesc propDesc) {
    Class paramType = propDesc.getPropertyType();
    if (paramType.isArray()) {
        paramType = paramType.getComponentType();
    }//  w w w.j a  va  2 s .  c om

    if (paramType.equals(Byte.class) || paramType.equals(Byte.TYPE)) {
        return "byte";
    } else if (Date.class.isAssignableFrom(paramType)) {
        return "date";
    } else if (paramType.equals(Double.class) || paramType.equals(Double.TYPE)) {
        return "double";
    } else if (paramType.equals(Float.class) || paramType.equals(Float.TYPE)) {
        return "float";
    } else if (paramType.equals(Integer.class) || paramType.equals(Integer.TYPE)) {
        return "integer";
    } else if (paramType.equals(Long.class) || paramType.equals(Long.TYPE)) {
        return "long";
    } else if (paramType.equals(Short.class) || paramType.equals(Short.TYPE)) {
        return "short";
    }

    return null;
}

From source file:com.link_intersystems.lang.Conversions.java

/**
 * # double to byte, short, char, int, long, or float
 *///from  ww w . j av a 2  s  . c o  m
private static boolean isPrimitiveDoubleNarrowing(Class<?> to) {
    boolean isNarrowing = isPrimitiveFloatNarrowing(to);

    isNarrowing |= isIdentity(to, Float.TYPE);

    return isNarrowing;
}

From source file:org.broadinstitute.gatk.queue.extensions.gatk.ArgumentField.java

/**
 * @param argType The class to check for options.
 * @return true if option should be used.
 *//*w ww.  ja va  2s . com*/
protected static boolean useFormatter(Class<?> argType) {
    return (argType.equals(Double.class) || argType.equals(Double.TYPE) || argType.equals(Float.class)
            || argType.equals(Float.TYPE));
}

From source file:org.eiichiro.bootleg.AbstractRequest.java

/**
 * Returns the default value of the specified primitive type.
 * /* w  w w.  j a v  a 2  s. com*/
 * @param type The primitive type.
 * @return The default value of the specified primitive type.
 */
protected Object primitive(Type type) {
    Class<?> rawType = Types.getRawType(type);

    if (rawType.equals(Boolean.TYPE)) {
        return (boolean) false;
    } else if (rawType.equals(Character.TYPE)) {
        return (char) 0;
    } else if (rawType.equals(Byte.TYPE)) {
        return (byte) 0;
    } else if (rawType.equals(Double.TYPE)) {
        return (double) 0.0;
    } else if (rawType.equals(Float.TYPE)) {
        return (float) 0.0;
    } else if (rawType.equals(Integer.TYPE)) {
        return (int) 0;
    } else {
        // short.
        return (short) 0;
    }
}

From source file:org.evosuite.testcase.fm.MethodDescriptor.java

public Object executeMatcher(int i) throws IllegalArgumentException {
    if (i < 0 || i >= getNumberOfInputParameters()) {
        throw new IllegalArgumentException("Invalid index: " + i);
    }/*w  ww  .ja va 2 s.c o  m*/

    Type[] types = method.getParameterTypes();
    Type type = types[i];

    try {
        if (type.equals(Integer.TYPE) || type.equals(Integer.class)) {
            return Mockito.anyInt();
        } else if (type.equals(Long.TYPE) || type.equals(Long.class)) {
            return Mockito.anyLong();
        } else if (type.equals(Boolean.TYPE) || type.equals(Boolean.class)) {
            return Mockito.anyBoolean();
        } else if (type.equals(Double.TYPE) || type.equals(Double.class)) {
            return Mockito.anyDouble();
        } else if (type.equals(Float.TYPE) || type.equals(Float.class)) {
            return Mockito.anyFloat();
        } else if (type.equals(Short.TYPE) || type.equals(Short.class)) {
            return Mockito.anyShort();
        } else if (type.equals(Character.TYPE) || type.equals(Character.class)) {
            return Mockito.anyChar();
        } else if (type.equals(String.class)) {
            return Mockito.anyString();
        } else {
            return Mockito.any(type.getClass());
        }
    } catch (Exception e) {
        logger.error("Failed to executed Mockito matcher n{} of type {} in {}.{}: {}", i, type, className,
                methodName, e.getMessage());
        throw new EvosuiteError(e);
    }
}

From source file:org.primeframework.mvc.parameter.convert.converters.NumberConverterTest.java

/**
 * Test the conversion from Strings./*w w w.  ja v a  2 s .  c o  m*/
 */
@Test
public void toStrings() {
    GlobalConverter converter = new NumberConverter(new MockConfiguration());
    String str = converter.convertToString(Integer.class, null, "testExpr", null);
    assertNull(str);

    str = converter.convertToString(Byte.class, null, "testExpr", (byte) 42);
    assertEquals(str, "42");

    str = converter.convertToString(Byte.TYPE, null, "testExpr", (byte) 42);
    assertEquals(str, "42");

    str = converter.convertToString(Short.class, null, "testExpr", (short) 42);
    assertEquals(str, "42");

    str = converter.convertToString(Short.TYPE, null, "testExpr", (short) 42);
    assertEquals(str, "42");

    str = converter.convertToString(Integer.class, null, "testExpr", 42);
    assertEquals(str, "42");

    str = converter.convertToString(Integer.class, null, "testExpr", 42);
    assertEquals(str, "42");

    str = converter.convertToString(Long.class, null, "testExpr", 42l);
    assertEquals(str, "42");

    str = converter.convertToString(Long.TYPE, null, "testExpr", 42l);
    assertEquals(str, "42");

    str = converter.convertToString(Float.class, null, "testExpr", 42f);
    assertEquals(str, "42.0");

    str = converter.convertToString(Float.TYPE, null, "testExpr", 42f);
    assertEquals(str, "42.0");

    str = converter.convertToString(Double.class, null, "testExpr", 42.0);
    assertEquals(str, "42.0");

    str = converter.convertToString(Double.TYPE, null, "testExpr", 42.0);
    assertEquals(str, "42.0");
}

From source file:org.opoo.util.ClassUtils.java

public static boolean isCompatibleType(Object value, Class type) {
    // Do object check first, then primitives
    if (value == null || type.isInstance(value)) {
        return true;
    } else if (type.equals(Integer.TYPE) && Integer.class.isInstance(value)) {
        return true;
    } else if (type.equals(Long.TYPE) && Long.class.isInstance(value)) {
        return true;
    } else if (type.equals(Double.TYPE) && Double.class.isInstance(value)) {
        return true;
    } else if (type.equals(Float.TYPE) && Float.class.isInstance(value)) {
        return true;
    } else if (type.equals(Short.TYPE) && Short.class.isInstance(value)) {
        return true;
    } else if (type.equals(Byte.TYPE) && Byte.class.isInstance(value)) {
        return true;
    } else if (type.equals(Character.TYPE) && Character.class.isInstance(value)) {
        return true;
    } else if (type.equals(Boolean.TYPE) && Boolean.class.isInstance(value)) {
        return true;
    } else {//from   w w  w.j  av a  2 s . c  om
        return false;
    }
}

From source file:com.nfwork.dbfound.json.JSONDynaBean.java

private boolean isFloat(Class clazz) {
    return Float.class.isAssignableFrom(clazz) || clazz == Float.TYPE;
}

From source file:pe.com.mmh.sisgap.utils.BasicDynaBean.java

/**
 * Return the value of a simple property with the specified name.
 *
 * @param name Name of the property whose value is to be retrieved
 *
 * @exception IllegalArgumentException if there is no property
 *  of the specified name//from   w w  w. ja v a2  s. c  o m
 */
public Object get(String name) {

    // Return any non-null value for the specified property
    Object value = values.get(name);
    if (value != null) {
        return (value);
    }

    // Return a null value for a non-primitive property
    Class type = getDynaProperty(name).getType();
    if (!type.isPrimitive()) {
        return (value);
    }

    // Manufacture default values for primitive properties
    if (type == Boolean.TYPE) {
        return (Boolean.FALSE);
    } else if (type == Byte.TYPE) {
        return (new Byte((byte) 0));
    } else if (type == Character.TYPE) {
        return (new Character((char) 0));
    } else if (type == Double.TYPE) {
        return (new Double((double) 0.0));
    } else if (type == Float.TYPE) {
        return (new Float((float) 0.0));
    } else if (type == Integer.TYPE) {
        return (new Integer((int) 0));
    } else if (type == Long.TYPE) {
        return (new Long((int) 0));
    } else if (type == Short.TYPE) {
        return (new Short((short) 0));
    } else {
        return (null);
    }

}

From source file:org.openspaces.rest.utils.ControllerUtils.java

public static Object convertPropertyToPrimitiveType(String object, Class type, String propKey) {
    if (type.equals(Long.class) || type.equals(Long.TYPE))
        return Long.valueOf(object);

    if (type.equals(Boolean.class) || type.equals(Boolean.TYPE))
        return Boolean.valueOf(object);

    if (type.equals(Integer.class) || type.equals(Integer.TYPE))
        return Integer.valueOf(object);

    if (type.equals(Byte.class) || type.equals(Byte.TYPE))
        return Byte.valueOf(object);

    if (type.equals(Short.class) || type.equals(Short.TYPE))
        return Short.valueOf(object);

    if (type.equals(Float.class) || type.equals(Float.TYPE))
        return Float.valueOf(object);

    if (type.equals(Double.class) || type.equals(Double.TYPE))
        return Double.valueOf(object);

    if (type.isEnum())
        return Enum.valueOf(type, object);

    if (type.equals(String.class) || type.equals(Object.class))
        return String.valueOf(object);

    if (type.equals(java.util.Date.class)) {
        try {/*from w w  w .j  a  v  a 2  s  . c o  m*/
            return simpleDateFormat.parse(object);
        } catch (ParseException e) {
            throw new RestException(
                    "Unable to parse date [" + object + "]. Make sure it matches the format: " + date_format);
        }
    }

    //unknown type
    throw new UnsupportedTypeException("Non primitive type when converting property [" + propKey + "]:" + type);
}