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:Main.java

public static void main(String[] args) {

    System.out.println("TYPE = " + Long.TYPE);

}

From source file:Main.java

public static void main(String[] args) {
    Class c = boolean.class;
    c = Boolean.TYPE;/*from w ww .  j a va 2  s .  c  o  m*/
    c = byte.class;
    c = Byte.TYPE;
    c = char.class;
    c = Character.TYPE;
    c = short.class;
    c = Short.TYPE;
    c = int.class;
    c = Integer.TYPE;
    c = long.class;
    c = Long.TYPE;
    c = float.class;
    c = Float.TYPE;
    c = double.class;
    c = Double.TYPE;
    c = void.class;
    c = Void.TYPE;
}

From source file:BeanUtilsExampleV4.java

  public static void main(String args[]) throws Exception {
    BeanUtilsExampleV4 diff = new BeanUtilsExampleV4();
    Actor actor = diff.prepareData();/*from  w  w w  . j av  a 2 s  . c o  m*/

    ConvertUtilsBean convertUtilsBean = new ConvertUtilsBean();
    convertUtilsBean.deregister(String.class);
    convertUtilsBean.register(new MyStringConverter(), String.class);

    convertUtilsBean.deregister(Long.class);
    convertUtilsBean.register(new MyLongConverter(), Long.class);
    convertUtilsBean.register(new MyLongConverter(), Long.TYPE);

    BeanUtilsBean beanUtilsBean =
      new BeanUtilsBean(convertUtilsBean, new PropertyUtilsBean());

    System.err.println("==== Values before calling describe ==== ");
    System.err.println("By PropertyUtils: " +
      PropertyUtils.getProperty(actor, "name"));
    System.err.println("By BeanUtils: " +
      beanUtilsBean.getProperty(actor, "name"));
    System.err.println(beanUtilsBean.getProperty(actor, "worth"));

    Map describedData = beanUtilsBean.describe(actor);

    // check the map
    System.err.println("==== Values in Map ==== ");
    System.err.println(describedData.get("name"));
    System.err.println(describedData.get("worth"));

    // create a new Actor Bean
    Actor newActor = new Actor();
    beanUtilsBean.populate(newActor, describedData);

    System.err.println("==== Values after calling populate ==== ");
    System.err.println(beanUtilsBean.getProperty(newActor, "name"));
    System.err.println(beanUtilsBean.getProperty(newActor, "worth"));

}

From source file:Main.java

public static Class<?> wrapperType(Class<?> paramClass) {
    if (paramClass == Integer.TYPE)
        return Integer.class;
    if (paramClass == Long.TYPE)
        return Long.class;
    if (paramClass == Boolean.TYPE)
        return Boolean.class;
    if (paramClass == Double.TYPE)
        return Double.class;
    if (paramClass == Float.TYPE)
        return Float.class;
    if (paramClass == Byte.TYPE)
        return Byte.class;
    if (paramClass == Short.TYPE)
        return Short.class;
    if (paramClass == Character.TYPE)
        return Character.class;
    throw new IllegalArgumentException("Class " + paramClass.getName() + " is not a primitive type");
}

From source file:Main.java

public static void keep_setLong(Field field, Object obj, Cursor cursor, int i) {
    try {/* w  ww . j ava2 s  .  com*/
        if (field.getType().equals(Long.TYPE))
            field.setLong(obj, cursor.getLong(i));
        else
            field.set(obj, Long.valueOf(cursor.getLong(i)));
    } catch (Exception exception) {
        exception.printStackTrace();
    }
}

From source file:Main.java

/**
 * Helper method used to get default value for wrappers used for primitive types
 * (0 for Integer etc)//  w  ww . j  a  v  a  2s.  c  o  m
 */
public static Object defaultValue(Class<?> cls) {
    if (cls == Integer.TYPE) {
        return Integer.valueOf(0);
    }
    if (cls == Long.TYPE) {
        return Long.valueOf(0L);
    }
    if (cls == Boolean.TYPE) {
        return Boolean.FALSE;
    }
    if (cls == Double.TYPE) {
        return Double.valueOf(0.0);
    }
    if (cls == Float.TYPE) {
        return Float.valueOf(0.0f);
    }
    if (cls == Byte.TYPE) {
        return Byte.valueOf((byte) 0);
    }
    if (cls == Short.TYPE) {
        return Short.valueOf((short) 0);
    }
    if (cls == Character.TYPE) {
        return '\0';
    }
    throw new IllegalArgumentException("Class " + cls.getName() + " is not a primitive type");
}

From source file:Main.java

/**
 * Helper method for finding wrapper type for given primitive type (why isn't
 * there one in JDK?)/* w  w  w.  j a  v a2  s .  com*/
 */
public static Class<?> wrapperType(Class<?> primitiveType) {
    if (primitiveType == Integer.TYPE) {
        return Integer.class;
    }
    if (primitiveType == Long.TYPE) {
        return Long.class;
    }
    if (primitiveType == Boolean.TYPE) {
        return Boolean.class;
    }
    if (primitiveType == Double.TYPE) {
        return Double.class;
    }
    if (primitiveType == Float.TYPE) {
        return Float.class;
    }
    if (primitiveType == Byte.TYPE) {
        return Byte.class;
    }
    if (primitiveType == Short.TYPE) {
        return Short.class;
    }
    if (primitiveType == Character.TYPE) {
        return Character.class;
    }
    throw new IllegalArgumentException("Class " + primitiveType.getName() + " is not a primitive type");
}

From source file:Main.java

public static Class<?> findClass(String className) throws ClassNotFoundException {
    // [JACKSON-597]: support primitive types (and void)
    if (className.indexOf('.') < 0) {
        if ("int".equals(className))
            return Integer.TYPE;
        if ("long".equals(className))
            return Long.TYPE;
        if ("float".equals(className))
            return Float.TYPE;
        if ("double".equals(className))
            return Double.TYPE;
        if ("boolean".equals(className))
            return Boolean.TYPE;
        if ("byte".equals(className))
            return Byte.TYPE;
        if ("char".equals(className))
            return Character.TYPE;
        if ("short".equals(className))
            return Short.TYPE;
        if ("void".equals(className))
            return Void.TYPE;
    }/*www. ja  v a  2s.c o m*/
    // Two-phase lookup: first using context ClassLoader; then default
    Throwable prob = null;
    ClassLoader loader = Thread.currentThread().getContextClassLoader();

    if (loader != null) {
        try {
            return Class.forName(className, true, loader);
        } catch (Exception e) {
            prob = getRootCause(e);
        }
    }
    try {
        return Class.forName(className);
    } catch (Exception e) {
        if (prob == null) {
            prob = getRootCause(e);
        }
    }
    if (prob instanceof RuntimeException) {
        throw (RuntimeException) prob;
    }
    throw new ClassNotFoundException(prob.getMessage(), prob);
}

From source file:Main.java

private static Map<Class<?>, Class<?>> getWrapperTypes() {
    Map<Class<?>, Class<?>> ret = new HashMap<Class<?>, Class<?>>();
    ret.put(Boolean.TYPE, Boolean.class);
    ret.put(Character.TYPE, Character.class);
    ret.put(Byte.TYPE, Byte.class);
    ret.put(Short.TYPE, Short.class);
    ret.put(Integer.TYPE, Integer.class);
    ret.put(Long.TYPE, Long.class);
    ret.put(Float.TYPE, Float.class);
    ret.put(Double.TYPE, Double.class);
    ret.put(Void.TYPE, Void.class);
    return ret;//from   www .  j a  va2 s . co  m
}

From source file:Main.java

public static void addBaseClassMappings() {
    mappings.put("byte", Byte.TYPE);
    mappings.put("short", Short.TYPE);
    mappings.put("int", Integer.TYPE);
    mappings.put("long", Long.TYPE);
    mappings.put("float", Float.TYPE);
    mappings.put("double", Double.TYPE);
    mappings.put("boolean", Boolean.TYPE);
    mappings.put("char", Character.TYPE);
    mappings.put("[byte", byte[].class);
    mappings.put("[short", short[].class);
    mappings.put("[int", int[].class);
    mappings.put("[long", long[].class);
    mappings.put("[float", float[].class);
    mappings.put("[double", double[].class);
    mappings.put("[boolean", boolean[].class);
    mappings.put("[char", char[].class);
    mappings.put(HashMap.class.getName(), HashMap.class);
}