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:clientapi.command.executor.parser.impl.NumberParser.java

@Override
public final boolean isTarget(Type type) {
    if (!(type instanceof Class)) {
        return false;
    }//from  w ww . ja v a 2s  . co  m

    Class c = (Class) type;
    // Check all NumberUtils#createNumber(String) supported types
    // Integer -> BigInteger
    // Float -> BigDecimal
    return Integer.class.isAssignableFrom(c) || Long.class.isAssignableFrom(c)
            || BigInteger.class.isAssignableFrom(c) || Float.class.isAssignableFrom(c)
            || Double.class.isAssignableFrom(c) || BigDecimal.class.isAssignableFrom(c)
            || Integer.TYPE.isAssignableFrom(c) || Long.TYPE.isAssignableFrom(c)
            || Float.TYPE.isAssignableFrom(c) || Double.TYPE.isAssignableFrom(c);
}

From source file:org.lunarray.model.descriptor.util.PrimitiveUtil.java

/**
 * Default constructor./*from   w  w  w. j a  v a 2s  .c o  m*/
 */
private PrimitiveUtil() {
    this.primitivesToClasses = new HashMap<Class<?>, Class<?>>();
    this.primitivesToClasses.put(Byte.TYPE, Byte.class);
    this.primitivesToClasses.put(Integer.TYPE, Integer.class);
    this.primitivesToClasses.put(Double.TYPE, Double.class);
    this.primitivesToClasses.put(Float.TYPE, Float.class);
    this.primitivesToClasses.put(Long.TYPE, Long.class);
    this.primitivesToClasses.put(Short.TYPE, Short.class);
    this.primitivesToClasses.put(Character.TYPE, Character.class);
    this.primitivesToClasses.put(Boolean.TYPE, Boolean.class);
}

From source file:Main.java

/**
 * <p>Inserts the specified element at the specified position in the array. 
 * Shifts the element currently at that position (if any) and any subsequent
 * elements to the right (adds one to their indices).</p>
 *
 * <p>This method returns a new array with the same elements of the input
 * array plus the given element on the specified position. The component 
 * type of the returned array is always the same as that of the input 
 * array.</p>//  w ww  .j  av  a  2  s. co m
 *
 * <p>If the input array is <code>null</code>, a new one element array is returned
 *  whose component type is the same as the element.</p>
 * 
 * <pre>
 * ArrayUtils.add([1.1f], 0, 2.2f)               = [2.2f, 1.1f]
 * ArrayUtils.add([2.3f, 6.4f], 2, 10.5f)        = [2.3f, 6.4f, 10.5f]
 * ArrayUtils.add([2.6f, 6.7f], 0, -4.8f)        = [-4.8f, 2.6f, 6.7f]
 * ArrayUtils.add([2.9f, 6.0f, 0.3f], 2, 1.0f)   = [2.9f, 6.0f, 1.0f, 0.3f]
 * </pre>
 * 
 * @param array  the array to add the element to, may be <code>null</code>
 * @param index  the position of the new object
 * @param element  the object to add
 * @return A new array containing the existing elements and the new element
 * @throws IndexOutOfBoundsException if the index is out of range 
 * (index < 0 || index > array.length).
 */
public static float[] add(float[] array, int index, float element) {
    return (float[]) add(array, index, new Float(element), Float.TYPE);
}

From source file:org.kordamp.ezmorph.object.NumberMorpher.java

/**
 * Creates a new morpher for the target type.
 *
 * @param type must be a primitive or wrapper type. BigDecimal and BigInteger
 *             are also supported.//from  w  w w. j a  va2 s.  c  o  m
 */
public NumberMorpher(Class<?> type) {
    super(false);

    if (type == null) {
        throw new MorphException("Must specify a type");
    }

    if (type != Byte.TYPE && type != Short.TYPE && type != Integer.TYPE && type != Long.TYPE
            && type != Float.TYPE && type != Double.TYPE && !Byte.class.isAssignableFrom(type)
            && !Short.class.isAssignableFrom(type) && !Integer.class.isAssignableFrom(type)
            && !Long.class.isAssignableFrom(type) && !Float.class.isAssignableFrom(type)
            && !Double.class.isAssignableFrom(type) && !BigInteger.class.isAssignableFrom(type)
            && !BigDecimal.class.isAssignableFrom(type)) {
        throw new MorphException("Must specify a Number subclass");
    }

    this.type = type;
}

From source file:com.csipsimple.backup.Columns.java

public Columns(String[] names, Class<?>[] classes) {
    this.names = new ArrayList<String>(Arrays.asList(names));
    types = new ArrayList<Type>(names.length);
    for (int i = 0; i < names.length; i++) {

        if (classes[i] == String.class) {
            types.add(i, Type.STRING);
        } else if (classes[i] == Integer.TYPE || classes[i] == Integer.class) {
            types.add(i, Type.INT);
        } else if (classes[i] == Long.TYPE || classes[i] == Long.class) {
            types.add(i, Type.LONG);
        } else if (classes[i] == Float.TYPE || classes[i] == Float.class) {
            types.add(i, Type.FLOAT);
        } else if (classes[i] == Double.TYPE || classes[i] == Double.class) {
            types.add(i, Type.DOUBLE);
        } else if (classes[i] == Boolean.TYPE || classes[i] == Boolean.class) {
            types.add(i, Type.BOOLEAN);
        }/*from w  ww. ja va 2  s  .c  om*/
    }
}

From source file:loon.LGame.java

private static Class<?> getType(Object o) {
    if (o instanceof Integer) {
        return Integer.TYPE;
    } else if (o instanceof Float) {
        return Float.TYPE;
    } else if (o instanceof Double) {
        return Double.TYPE;
    } else if (o instanceof Long) {
        return Long.TYPE;
    } else if (o instanceof Short) {
        return Short.TYPE;
    } else if (o instanceof Short) {
        return Short.TYPE;
    } else if (o instanceof Boolean) {
        return Boolean.TYPE;
    } else {/*from   w ww  .  j  ava  2  s.  c o  m*/
        return o.getClass();
    }
}

From source file:org.kuali.rice.krad.util.DataTypeUtil.java

/**
 * Determines if the given class is enough like a Float to store values of it as a SearchableAttributeFloatValue
 * @param type the class to determine of the type of
 * @return true if it is like a "float", false otherwise
 *///w  w w  .  j ava  2s  .c o m
public static boolean isDecimaltastic(Class<?> type) {
    return java.lang.Double.class.isAssignableFrom(type) || java.lang.Float.class.isAssignableFrom(type)
            || type.equals(Double.TYPE) || type.equals(Float.TYPE)
            || java.math.BigDecimal.class.isAssignableFrom(type)
            || org.kuali.rice.core.api.util.type.KualiDecimal.class.isAssignableFrom(type);
}

From source file:org.fhcrc.cpl.viewer.util.ConvertHelper.java

protected void register() {
    super.register();

    ConvertUtils.register(new MyBooleanConverter(), Boolean.TYPE);
    ConvertUtils.register(new NullSafeConverter(new MyBooleanConverter()), Boolean.class);
    ConvertUtils.register(new NullSafeConverter(new ByteArrayConverter()), byte[].class);
    ConvertUtils.register(new PercentWrapper(new DoubleConverter()), Double.TYPE);
    ConvertUtils.register(new NullSafeConverter(new PercentWrapper(new DoubleConverter())), Double.class);
    ConvertUtils.register(new PercentWrapper(new FloatConverter()), Float.TYPE);
    ConvertUtils.register(new NullSafeConverter(new PercentWrapper(new FloatConverter())), Float.class);
    ConvertUtils.register(new ChargeWrapper(new IntegerConverter()), Integer.TYPE);
    ConvertUtils.register(new NullSafeConverter(new ChargeWrapper(new IntegerConverter())), Integer.class);
    ConvertUtils.register(new NullSafeConverter(new DateFriendlyStringConverter()), String.class);
    ConvertUtils.register(new LenientTimestampConverter(), java.sql.Timestamp.class);
    ConvertUtils.register(new LenientDateConverter(), java.util.Date.class);
}

From source file:org.openamf.util.OpenAMFUtils.java

public static boolean typesMatch(Class parameterType, Object parameter) {
    log.debug("expected class: " + parameterType.getName());
    if (parameter == null) {
        log.debug("parameter is null");
    } else {/*from w ww . j  a va 2 s . c o m*/
        log.debug("parameter class: " + parameter.getClass().getName());
    }
    boolean typesMatch = parameterType.isInstance(parameter);
    if (!typesMatch) {
        if (parameterType.equals(Boolean.TYPE) && parameter instanceof Boolean) {
            typesMatch = true;
        } else if (parameterType.equals(Character.TYPE) && parameter instanceof Character) {
            typesMatch = true;
        } else if (parameterType.equals(Byte.TYPE) && parameter instanceof Byte) {
            typesMatch = true;
        } else if (parameterType.equals(Short.TYPE) && parameter instanceof Short) {
            typesMatch = true;
        } else if (parameterType.equals(Integer.TYPE) && parameter instanceof Integer) {
            typesMatch = true;
        } else if (parameterType.equals(Long.TYPE) && parameter instanceof Long) {
            typesMatch = true;
        } else if (parameterType.equals(Float.TYPE) && parameter instanceof Float) {
            typesMatch = true;
        } else if (parameterType.equals(Double.TYPE) && parameter instanceof Double) {
            typesMatch = true;
        }
    }
    return typesMatch;
}

From source file:org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.TestQueueCapacities.java

private static float executeByName(QueueCapacities obj, String methodName, String label, float value)
        throws Exception {
    // We have 4 kinds of method
    // 1. getXXX() : float
    // 2. getXXX(label) : float
    // 3. setXXX(float) : void
    // 4. setXXX(label, float) : void
    if (methodName.startsWith("get")) {
        float result;
        if (label == null) {
            // 1.
            Method method = QueueCapacities.class.getDeclaredMethod(methodName);
            result = (float) method.invoke(obj);
        } else {//  w  w  w. j a  v  a2  s.  co m
            // 2.
            Method method = QueueCapacities.class.getDeclaredMethod(methodName, String.class);
            result = (float) method.invoke(obj, label);
        }
        return result;
    } else {
        if (label == null) {
            // 3.
            Method method = QueueCapacities.class.getDeclaredMethod(methodName, Float.TYPE);
            method.invoke(obj, value);
        } else {
            // 4.
            Method method = QueueCapacities.class.getDeclaredMethod(methodName, String.class, Float.TYPE);
            method.invoke(obj, label, value);
        }
        return -1f;
    }
}