Example usage for java.lang Long TYPE

List of usage examples for java.lang Long TYPE

Introduction

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

Prototype

Class TYPE

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

Click Source Link

Document

The Class instance representing the primitive type long .

Usage

From source file:org.impalaframework.spring.DebuggingInterceptor.java

public Object invoke(MethodInvocation invocation) throws Throwable {

    logger.debug("Calling method " + invocation);
    Class<?> returnType = invocation.getMethod().getReturnType();

    if (Void.TYPE.equals(returnType))
        return null;
    if (Byte.TYPE.equals(returnType))
        return (byte) 0;
    if (Short.TYPE.equals(returnType))
        return (short) 0;
    if (Integer.TYPE.equals(returnType))
        return (int) 0;
    if (Long.TYPE.equals(returnType))
        return 0L;
    if (Float.TYPE.equals(returnType))
        return 0f;
    if (Double.TYPE.equals(returnType))
        return 0d;
    if (Boolean.TYPE.equals(returnType))
        return false;

    return null;/*ww  w .j  ava 2s . c om*/
}

From source file:org.dhatim.javabean.BeanUtils.java

/**
 * Create the bean setter method instance for this visitor.
 *
 * @param setterName The setter method name.
 * @param setterParamType//from  w  ww  .  j  a  v  a 2s.c  o m
 * @return The bean setter method.
 */
public static Method createSetterMethod(String setterName, Object bean, Class<?> setterParamType) {
    Method beanSetterMethod = ClassUtil.getSetterMethod(setterName, bean, setterParamType);

    // Try it as a list...
    if (beanSetterMethod == null && List.class.isAssignableFrom(setterParamType)) {
        String setterNamePlural = setterName + "s";

        // Try it as a List using the plural name...
        beanSetterMethod = ClassUtil.getSetterMethod(setterNamePlural, bean, setterParamType);
        if (beanSetterMethod == null) {
            // Try it as an array using the non-plural name...
        }
    }

    // Try it as a primitive...
    if (beanSetterMethod == null && Integer.class.isAssignableFrom(setterParamType)) {
        beanSetterMethod = ClassUtil.getSetterMethod(setterName, bean, Integer.TYPE);
    }
    if (beanSetterMethod == null && Long.class.isAssignableFrom(setterParamType)) {
        beanSetterMethod = ClassUtil.getSetterMethod(setterName, bean, Long.TYPE);
    }
    if (beanSetterMethod == null && Float.class.isAssignableFrom(setterParamType)) {
        beanSetterMethod = ClassUtil.getSetterMethod(setterName, bean, Float.TYPE);
    }
    if (beanSetterMethod == null && Double.class.isAssignableFrom(setterParamType)) {
        beanSetterMethod = ClassUtil.getSetterMethod(setterName, bean, Double.TYPE);
    }
    if (beanSetterMethod == null && Character.class.isAssignableFrom(setterParamType)) {
        beanSetterMethod = ClassUtil.getSetterMethod(setterName, bean, Character.TYPE);
    }
    if (beanSetterMethod == null && Short.class.isAssignableFrom(setterParamType)) {
        beanSetterMethod = ClassUtil.getSetterMethod(setterName, bean, Short.TYPE);
    }
    if (beanSetterMethod == null && Byte.class.isAssignableFrom(setterParamType)) {
        beanSetterMethod = ClassUtil.getSetterMethod(setterName, bean, Byte.TYPE);
    }
    if (beanSetterMethod == null && Boolean.class.isAssignableFrom(setterParamType)) {
        beanSetterMethod = ClassUtil.getSetterMethod(setterName, bean, Boolean.TYPE);
    }

    return beanSetterMethod;
}

From source file:com.bedatadriven.rebar.persistence.mapping.PrimitiveMapping.java

public PrimitiveMapping(MethodInfo getter) {
    super(getter);

    TypeInfo type = getter.getReturnType();
    Class primitive = type.isPrimitive();

    this.boxed = (primitive == null);

    if (primitive != null) {
        this.nullable = false;
    }//from   w ww . j  a  va  2 s  .  com

    if (primitive == Integer.TYPE || type.getQualifiedName().equals(Integer.class.getName())
            || primitive == Short.TYPE || type.getQualifiedName().equals(Short.class.getName())
            || primitive == Long.TYPE || type.getQualifiedName().equals(Long.class.getName())
            || primitive == Byte.TYPE || type.getQualifiedName().equals(Byte.class.getName())
            || primitive == Boolean.TYPE || type.getQualifiedName().equals(Boolean.class.getName())) {

        sqlTypeName = SqliteTypes.integer;

    } else if (primitive == Float.TYPE || type.getQualifiedName().equals(Float.class.getName())
            || primitive == Double.TYPE || type.getQualifiedName().equals(Double.class.getName())) {

        sqlTypeName = SqliteTypes.real;

    } else if (primitive == Character.TYPE || type.getQualifiedName().equals(Character.class.getName())) {

        sqlTypeName = SqliteTypes.text;
    }

    String suffix = type.getSimpleName();

    if (suffix.equals("Integer")) {
        suffix = "Int";
    } else if (suffix.equals("Character")) {
        suffix = "Char";
    }
    suffix = suffix.substring(0, 1).toUpperCase() + suffix.substring(1);

    readerName = "Readers.read" + suffix;
    stmtSetter = "set" + suffix;

}

From source file:Main.java

/**
 * <p>Copies the given array and adds the given element at the end of the new array.</p>
 *
 * <p>The new array contains the same elements of the input
 * array plus the given element in the last position. The component type of 
 * the new array is the same as that of the input array.</p>
 *
 * <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>
 * /*from   w  w  w. ja  va  2 s . c o m*/
 * <pre>
 * ArrayUtils.add(null, 0)   = [0]
 * ArrayUtils.add([1], 0)    = [1, 0]
 * ArrayUtils.add([1, 0], 1) = [1, 0, 1]
 * </pre>
 * 
 * @param array  the array to copy and add the element to, may be <code>null</code>
 * @param element  the object to add at the last index of the new array
 * @return A new array containing the existing elements plus the new element
 * @since 2.1
 */
public static long[] add(long[] array, long element) {
    long[] newArray = (long[]) copyArrayGrow1(array, Long.TYPE);
    newArray[newArray.length - 1] = element;
    return newArray;
}

From source file:com.textuality.lifesaver.Columns.java

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

        if (classes[i] == String.class)
            types[i] = Type.STRING;
        else if (classes[i] == Integer.TYPE || classes[i] == Integer.class)
            types[i] = Type.INT;// www  . j a  v a2  s . c o  m
        else if (classes[i] == Long.TYPE || classes[i] == Long.class)
            types[i] = Type.LONG;
        else if (classes[i] == Float.TYPE || classes[i] == Float.class)
            types[i] = Type.FLOAT;
        else if (classes[i] == Double.TYPE || classes[i] == Double.class)
            types[i] = Type.DOUBLE;
    }
}

From source file:io.github.benas.jpopulator.randomizers.validation.MaxValueRandomizer.java

/**
 * Generate a random value for the given type.
 *
 * @param type the type for which a random value will be generated
 * @param maxValue the maximum threshold for the generated value
 * @return a random value (lower than maxValue) for the given type or null if the type is not supported
 *//*from  ww  w  . j a  v  a2 s . com*/
public static Object getRandomValue(final Class type, final long maxValue) {

    if (type.equals(Byte.TYPE) || type.equals(Byte.class)) {
        return (byte) randomDataGenerator.nextLong(Byte.MIN_VALUE, maxValue);
    }
    if (type.equals(Short.TYPE) || type.equals(Short.class)) {
        return (short) randomDataGenerator.nextLong(Short.MIN_VALUE, maxValue);
    }
    if (type.equals(Integer.TYPE) || type.equals(Integer.class)) {
        return (int) randomDataGenerator.nextLong(Integer.MIN_VALUE, maxValue);
    }
    if (type.equals(Long.TYPE) || type.equals(Long.class)) {
        return randomDataGenerator.nextLong(Long.MIN_VALUE, maxValue);
    }
    if (type.equals(BigInteger.class)) {
        return new BigInteger(String.valueOf(randomDataGenerator.nextLong(Long.MIN_VALUE, maxValue)));
    }
    if (type.equals(BigDecimal.class)) {
        return new BigDecimal(randomDataGenerator.nextLong(Long.MIN_VALUE, maxValue));
    }
    return null;
}

From source file:io.github.benas.jpopulator.randomizers.validation.MinValueRandomizer.java

/**
 * Generate a random value for the given type.
 *
 * @param type the type for which a random value will be generated
 * @param minValue the minimum threshold for the generated value
 * @return a random value (greater than maxValue) for the given type or null if the type is not supported
 *//*w  w w .j a  v  a  2 s  .c  o  m*/
public static Object getRandomValue(final Class type, final long minValue) {

    if (type.equals(Byte.TYPE) || type.equals(Byte.class)) {
        return (byte) randomDataGenerator.nextLong(minValue, Byte.MAX_VALUE);
    }
    if (type.equals(Short.TYPE) || type.equals(Short.class)) {
        return (short) randomDataGenerator.nextLong(minValue, Short.MAX_VALUE);
    }
    if (type.equals(Integer.TYPE) || type.equals(Integer.class)) {
        return (int) randomDataGenerator.nextLong(minValue, Integer.MAX_VALUE);
    }
    if (type.equals(Long.TYPE) || type.equals(Long.class)) {
        return randomDataGenerator.nextLong(minValue, Long.MAX_VALUE);
    }
    if (type.equals(BigInteger.class)) {
        return new BigInteger(String.valueOf(randomDataGenerator.nextLong(minValue, Long.MAX_VALUE)));
    }
    if (type.equals(BigDecimal.class)) {
        return new BigDecimal(randomDataGenerator.nextLong(minValue, Long.MAX_VALUE));
    }
    return null;
}

From source file:org.wso2.carbon.analytics.spark.core.util.AnalyticsCommonUtils.java

public static DataType getDataType(Type returnType) throws AnalyticsUDFException {
    DataType udfReturnType = null;// w ww  .j  a va  2 s. c  om
    if (returnType == Integer.TYPE || returnType == Integer.class) {
        udfReturnType = DataTypes.IntegerType;
    } else if (returnType == Double.TYPE || returnType == Double.class) {
        udfReturnType = DataTypes.DoubleType;
    } else if (returnType == Float.TYPE || returnType == Float.class) {
        udfReturnType = DataTypes.FloatType;
    } else if (returnType == Long.TYPE || returnType == Long.class) {
        udfReturnType = DataTypes.LongType;
    } else if (returnType == Boolean.TYPE || returnType == Boolean.class) {
        udfReturnType = DataTypes.BooleanType;
    } else if (returnType == String.class) {
        udfReturnType = DataTypes.StringType;
    } else if (returnType == Short.TYPE || returnType == Short.class) {
        udfReturnType = DataTypes.ShortType;
    } else if (returnType == NullType.class) {
        udfReturnType = DataTypes.NullType;
    } else if (returnType == Byte.TYPE || returnType == Byte.class) {
        udfReturnType = DataTypes.ByteType;
    } else if (returnType == byte[].class || returnType == Byte[].class) {
        udfReturnType = DataTypes.BinaryType;
    } else if (returnType == Date.class) {
        udfReturnType = DataTypes.DateType;
    } else if (returnType == Timestamp.class) {
        udfReturnType = DataTypes.TimestampType;
    } else if (returnType == BigDecimal.class) {
        udfReturnType = DataTypes.createDecimalType();
    } else if (returnType instanceof ParameterizedType) {
        ParameterizedType type = (ParameterizedType) returnType;
        /*if return type is a List types will contain only 1 element, if return type is Map it will have
        2 elements types representing key and the value.*/
        Type[] types = type.getActualTypeArguments();
        if (types != null && types.length > 0) {
            switch (types.length) {
            case 1: {
                udfReturnType = DataTypes.createArrayType(getDataType(types[0]));
                break;
            }
            case 2: {
                udfReturnType = DataTypes.createMapType(getDataType(types[0]), getDataType(types[1]));
                break;
            }
            default:
                throw new AnalyticsUDFException("Cannot Map the return type either to ArrayType or MapType");
            }
        }
    } else {
        throw new AnalyticsUDFException("Cannot determine the return DataType");
    }
    return udfReturnType;
}

From source file:com.github.steveash.typedconfig.resolver.type.simple.LongValueResolverFactory.java

@Override
public boolean canResolveFor(ConfigBinding configBinding) {
    return configBinding.getDataType().isAssignableFrom(Long.class)
            || configBinding.getDataType().isAssignableFrom(Long.TYPE);
}

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 .  j  a  va2 s  .c om

    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);
}