Example usage for java.lang Double TYPE

List of usage examples for java.lang Double TYPE

Introduction

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

Prototype

Class TYPE

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

Click Source Link

Document

The Class instance representing the primitive type double .

Usage

From source file:candr.yoclip.option.OptionSetter.java

@Override
public void setOption(final T bean, final String value) {

    final Class<?> setterParameterType = getType();
    try {/*  w ww  .j a  va 2  s  . c  om*/

        if (Boolean.TYPE.equals(setterParameterType) || Boolean.class.isAssignableFrom(setterParameterType)) {
            setBooleanOption(bean, value);

        } else if (Byte.TYPE.equals(setterParameterType) || Byte.class.isAssignableFrom(setterParameterType)) {
            setByteOption(bean, value);

        } else if (Short.TYPE.equals(setterParameterType)
                || Short.class.isAssignableFrom(setterParameterType)) {
            setShortOption(bean, value);

        } else if (Integer.TYPE.equals(setterParameterType)
                || Integer.class.isAssignableFrom(setterParameterType)) {
            setIntegerOption(bean, value);

        } else if (Long.TYPE.equals(setterParameterType) || Long.class.isAssignableFrom(setterParameterType)) {
            setLongOption(bean, value);

        } else if (Character.TYPE.equals(setterParameterType)
                || Character.class.isAssignableFrom(setterParameterType)) {
            setCharacterOption(bean, value);

        } else if (Float.TYPE.equals(setterParameterType)
                || Float.class.isAssignableFrom(setterParameterType)) {
            setFloatOption(bean, value);

        } else if (Double.TYPE.equals(setterParameterType)
                || Double.class.isAssignableFrom(setterParameterType)) {
            setDoubleOption(bean, value);

        } else if (String.class.isAssignableFrom(setterParameterType)) {
            setStringOption(bean, value);

        } else {
            final String supportedTypes = "boolean, byte, short, int, long, char, float, double, and String";
            throw new OptionsParseException(
                    String.format("OptionParameter only supports %s types", supportedTypes));
        }

    } catch (NumberFormatException e) {
        final String error = String.format("Error converting '%s' to %s", value, setterParameterType);
        throw new OptionsParseException(error, e);
    }
}

From source file:org.cocoa4android.util.sbjson.SBJsonWriter.java

/**
 *  //from w  ww. j av a  2s  .co m
 * @param clazz   
 * @return
 */
public static boolean isNumber(Class<?> clazz) {
    return (clazz != null) && ((Byte.TYPE.isAssignableFrom(clazz)) || (Short.TYPE.isAssignableFrom(clazz))
            || (Integer.TYPE.isAssignableFrom(clazz)) || (Long.TYPE.isAssignableFrom(clazz))
            || (Float.TYPE.isAssignableFrom(clazz)) || (Double.TYPE.isAssignableFrom(clazz))
            || (Number.class.isAssignableFrom(clazz)));
}

From source file:org.cloudata.core.common.io.CObjectWritable.java

/** Write a {@link CWritable}, {@link String}, primitive type, or an array of
 * the preceding. *//*from w  w  w.java  2  s. c o  m*/
public static void writeObject(DataOutput out, Object instance, Class declaredClass, CloudataConf conf,
        boolean arrayComponent) throws IOException {

    if (instance == null) { // null
        instance = new NullInstance(declaredClass, conf);
        declaredClass = CWritable.class;
        arrayComponent = false;
    }

    if (!arrayComponent) {
        CUTF8.writeString(out, declaredClass.getName()); // always write declared
        //System.out.println("Write:declaredClass.getName():" + declaredClass.getName());
    }

    if (declaredClass.isArray()) { // array
        int length = Array.getLength(instance);
        out.writeInt(length);
        //System.out.println("Write:length:" + length);

        if (declaredClass.getComponentType() == Byte.TYPE) {
            out.write((byte[]) instance);
        } else if (declaredClass.getComponentType() == ColumnValue.class) {
            //ColumnValue?  Deserialize? ?? ?   ?? ?  .
            writeColumnValue(out, instance, declaredClass, conf, length);
        } else {
            for (int i = 0; i < length; i++) {
                writeObject(out, Array.get(instance, i), declaredClass.getComponentType(), conf,
                        !declaredClass.getComponentType().isArray());
            }
        }
    } else if (declaredClass == String.class) { // String
        CUTF8.writeString(out, (String) instance);

    } else if (declaredClass.isPrimitive()) { // primitive type

        if (declaredClass == Boolean.TYPE) { // boolean
            out.writeBoolean(((Boolean) instance).booleanValue());
        } else if (declaredClass == Character.TYPE) { // char
            out.writeChar(((Character) instance).charValue());
        } else if (declaredClass == Byte.TYPE) { // byte
            out.writeByte(((Byte) instance).byteValue());
        } else if (declaredClass == Short.TYPE) { // short
            out.writeShort(((Short) instance).shortValue());
        } else if (declaredClass == Integer.TYPE) { // int
            out.writeInt(((Integer) instance).intValue());
        } else if (declaredClass == Long.TYPE) { // long
            out.writeLong(((Long) instance).longValue());
        } else if (declaredClass == Float.TYPE) { // float
            out.writeFloat(((Float) instance).floatValue());
        } else if (declaredClass == Double.TYPE) { // double
            out.writeDouble(((Double) instance).doubleValue());
        } else if (declaredClass == Void.TYPE) { // void
        } else {
            throw new IllegalArgumentException("Not a primitive: " + declaredClass);
        }
    } else if (declaredClass.isEnum()) { // enum
        CUTF8.writeString(out, ((Enum) instance).name());
    } else if (CWritable.class.isAssignableFrom(declaredClass)) { // Writable
        if (instance.getClass() == declaredClass) {
            out.writeShort(TYPE_SAME); // ? ?? ? ?? 
            //System.out.println("Write:TYPE_SAME:" + TYPE_SAME);

        } else {
            out.writeShort(TYPE_DIFF);
            //System.out.println("Write:TYPE_DIFF:" + TYPE_DIFF);
            CUTF8.writeString(out, instance.getClass().getName());
            //System.out.println("Write:instance.getClass().getName():" + instance.getClass().getName());
        }
        ((CWritable) instance).write(out);
        //System.out.println("Write:instance value");

    } else {
        throw new IOException("Can't write: " + instance + " as " + declaredClass);
    }
}

From source file:nz.co.senanque.validationengine.ConvertUtils.java

public static Object getPrimitiveTypeForNull(Class<?> clazz) {
    if (clazz.equals(Long.TYPE)) {
        return 0L;
    } else if (clazz.equals(Integer.TYPE)) {
        return 0;
    } else if (clazz.equals(Float.TYPE)) {
        return 0.0F;
    } else if (clazz.equals(Double.TYPE)) {
        return 0.0D;
    } else if (clazz.equals(Boolean.TYPE)) {
        return false;
    }/*from   ww w.j av  a 2s . com*/
    return null;
}

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}, a new one element array is returned
 *  whose component type is the same as the element.</p>
 *
 * <pre>// w w  w  . jav a  2s . co  m
 * 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}
 * @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 double[] add(final double[] array, final double element) {
    final double[] newArray = (double[]) copyArrayGrow1(array, Double.TYPE);
    newArray[newArray.length - 1] = element;
    return newArray;
}

From source file:org.apache.sling.models.impl.model.AbstractInjectableElement.java

private static Object getDefaultValue(AnnotatedElement element, Type type,
        InjectAnnotationProcessor2 annotationProcessor) {
    if (annotationProcessor != null && annotationProcessor.hasDefault()) {
        return annotationProcessor.getDefault();
    }//from  w  w w  . j  a va2  s.  c o  m

    Default defaultAnnotation = element.getAnnotation(Default.class);
    if (defaultAnnotation == null) {
        return null;
    }

    Object value = null;

    if (type instanceof Class) {
        Class<?> injectedClass = (Class<?>) type;
        if (injectedClass.isArray()) {
            Class<?> componentType = injectedClass.getComponentType();
            if (componentType == String.class) {
                value = defaultAnnotation.values();
            } else if (componentType == Integer.TYPE) {
                value = defaultAnnotation.intValues();
            } else if (componentType == Integer.class) {
                value = ArrayUtils.toObject(defaultAnnotation.intValues());
            } else if (componentType == Long.TYPE) {
                value = defaultAnnotation.longValues();
            } else if (componentType == Long.class) {
                value = ArrayUtils.toObject(defaultAnnotation.longValues());
            } else if (componentType == Boolean.TYPE) {
                value = defaultAnnotation.booleanValues();
            } else if (componentType == Boolean.class) {
                value = ArrayUtils.toObject(defaultAnnotation.booleanValues());
            } else if (componentType == Short.TYPE) {
                value = defaultAnnotation.shortValues();
            } else if (componentType == Short.class) {
                value = ArrayUtils.toObject(defaultAnnotation.shortValues());
            } else if (componentType == Float.TYPE) {
                value = defaultAnnotation.floatValues();
            } else if (componentType == Float.class) {
                value = ArrayUtils.toObject(defaultAnnotation.floatValues());
            } else if (componentType == Double.TYPE) {
                value = defaultAnnotation.doubleValues();
            } else if (componentType == Double.class) {
                value = ArrayUtils.toObject(defaultAnnotation.doubleValues());
            } else {
                log.warn("Default values for {} are not supported", componentType);
            }
        } else {
            if (injectedClass == String.class) {
                value = defaultAnnotation.values().length == 0 ? "" : defaultAnnotation.values()[0];
            } else if (injectedClass == Integer.class) {
                value = defaultAnnotation.intValues().length == 0 ? 0 : defaultAnnotation.intValues()[0];
            } else if (injectedClass == Long.class) {
                value = defaultAnnotation.longValues().length == 0 ? 0l : defaultAnnotation.longValues()[0];
            } else if (injectedClass == Boolean.class) {
                value = defaultAnnotation.booleanValues().length == 0 ? false
                        : defaultAnnotation.booleanValues()[0];
            } else if (injectedClass == Short.class) {
                value = defaultAnnotation.shortValues().length == 0 ? ((short) 0)
                        : defaultAnnotation.shortValues()[0];
            } else if (injectedClass == Float.class) {
                value = defaultAnnotation.floatValues().length == 0 ? 0f : defaultAnnotation.floatValues()[0];
            } else if (injectedClass == Double.class) {
                value = defaultAnnotation.doubleValues().length == 0 ? 0d : defaultAnnotation.doubleValues()[0];
            } else {
                log.warn("Default values for {} are not supported", injectedClass);
            }
        }
    } else {
        log.warn("Cannot provide default for {}", type);
    }
    return value;
}

From source file:au.com.addstar.cellblock.configuration.AutoConfig.java

@SuppressWarnings("unchecked")
public boolean load() {
    FileConfiguration yml = new YamlConfiguration();
    try {/*from   w w w.  ja  va 2  s  . co m*/
        if (mFile.getParentFile().exists() || mFile.getParentFile().mkdirs()) {// Make sure the file exists
            if (mFile.exists() || mFile.createNewFile()) {
                // Parse the config
                yml.load(mFile);
                for (Field field : getClass().getDeclaredFields()) {
                    ConfigField configField = field.getAnnotation(ConfigField.class);
                    if (configField == null)
                        continue;

                    String optionName = configField.name();
                    if (optionName.isEmpty())
                        optionName = field.getName();

                    field.setAccessible(true);

                    String path = (configField.category().isEmpty() ? "" : configField.category() + ".") //$NON-NLS-2$
                            + optionName;
                    if (!yml.contains(path)) {
                        if (field.get(this) == null)
                            throw new InvalidConfigurationException(
                                    path + " is required to be set! Info:\n" + configField.comment());
                    } else {
                        // Parse the value

                        if (field.getType().isArray()) {
                            // Integer
                            if (field.getType().getComponentType().equals(Integer.TYPE))
                                field.set(this, yml.getIntegerList(path).toArray(new Integer[0]));

                            // Float
                            else if (field.getType().getComponentType().equals(Float.TYPE))
                                field.set(this, yml.getFloatList(path).toArray(new Float[0]));

                            // Double
                            else if (field.getType().getComponentType().equals(Double.TYPE))
                                field.set(this, yml.getDoubleList(path).toArray(new Double[0]));

                            // Long
                            else if (field.getType().getComponentType().equals(Long.TYPE))
                                field.set(this, yml.getLongList(path).toArray(new Long[0]));

                            // Short
                            else if (field.getType().getComponentType().equals(Short.TYPE))
                                field.set(this, yml.getShortList(path).toArray(new Short[0]));

                            // Boolean
                            else if (field.getType().getComponentType().equals(Boolean.TYPE))
                                field.set(this, yml.getBooleanList(path).toArray(new Boolean[0]));

                            // String
                            else if (field.getType().getComponentType().equals(String.class)) {
                                field.set(this, yml.getStringList(path).toArray(new String[0]));
                            } else
                                throw new IllegalArgumentException("Cannot use type "
                                        + field.getType().getSimpleName() + " for AutoConfiguration"); //$NON-NLS-1$
                        } else if (List.class.isAssignableFrom(field.getType())) {
                            if (field.getGenericType() == null)
                                throw new IllegalArgumentException(
                                        "Cannot use type List without specifying generic type for AutoConfiguration");

                            Type type = ((ParameterizedType) field.getGenericType())
                                    .getActualTypeArguments()[0];

                            if (type.equals(Integer.class))
                                field.set(this, newList((Class<? extends List<Integer>>) field.getType(),
                                        yml.getIntegerList(path)));
                            else if (type.equals(Float.class))
                                field.set(this, newList((Class<? extends List<Float>>) field.getType(),
                                        yml.getFloatList(path)));
                            else if (type.equals(Double.class))
                                field.set(this, newList((Class<? extends List<Double>>) field.getType(),
                                        yml.getDoubleList(path)));
                            else if (type.equals(Long.class))
                                field.set(this, newList((Class<? extends List<Long>>) field.getType(),
                                        yml.getLongList(path)));
                            else if (type.equals(Short.class))
                                field.set(this, newList((Class<? extends List<Short>>) field.getType(),
                                        yml.getShortList(path)));
                            else if (type.equals(Boolean.class))
                                field.set(this, newList((Class<? extends List<Boolean>>) field.getType(),
                                        yml.getBooleanList(path)));
                            else if (type.equals(String.class))
                                field.set(this, newList((Class<? extends List<String>>) field.getType(),
                                        yml.getStringList(path)));
                            else
                                throw new IllegalArgumentException(
                                        "Cannot use type " + field.getType().getSimpleName() + "<" //$NON-NLS-2$
                                                + type.toString() + "> for AutoConfiguration");
                        } else if (Set.class.isAssignableFrom(field.getType())) {
                            if (field.getGenericType() == null)
                                throw new IllegalArgumentException(
                                        "Cannot use type set without specifying generic type for AytoConfiguration");

                            Type type = ((ParameterizedType) field.getGenericType())
                                    .getActualTypeArguments()[0];

                            if (type.equals(Integer.class))
                                field.set(this, newSet((Class<? extends Set<Integer>>) field.getType(),
                                        yml.getIntegerList(path)));
                            else if (type.equals(Float.class))
                                field.set(this, newSet((Class<? extends Set<Float>>) field.getType(),
                                        yml.getFloatList(path)));
                            else if (type.equals(Double.class))
                                field.set(this, newSet((Class<? extends Set<Double>>) field.getType(),
                                        yml.getDoubleList(path)));
                            else if (type.equals(Long.class))
                                field.set(this, newSet((Class<? extends Set<Long>>) field.getType(),
                                        yml.getLongList(path)));
                            else if (type.equals(Short.class))
                                field.set(this, newSet((Class<? extends Set<Short>>) field.getType(),
                                        yml.getShortList(path)));
                            else if (type.equals(Boolean.class))
                                field.set(this, newSet((Class<? extends Set<Boolean>>) field.getType(),
                                        yml.getBooleanList(path)));
                            else if (type.equals(String.class))
                                field.set(this, newSet((Class<? extends Set<String>>) field.getType(),
                                        yml.getStringList(path)));
                            else
                                throw new IllegalArgumentException(
                                        "Cannot use type " + field.getType().getSimpleName() + "<" //$NON-NLS-2$
                                                + type.toString() + "> for AutoConfiguration");
                        } else {
                            // Integer
                            if (field.getType().equals(Integer.TYPE))
                                field.setInt(this, yml.getInt(path));

                            // Float
                            else if (field.getType().equals(Float.TYPE))
                                field.setFloat(this, (float) yml.getDouble(path));

                            // Double
                            else if (field.getType().equals(Double.TYPE))
                                field.setDouble(this, yml.getDouble(path));

                            // Long
                            else if (field.getType().equals(Long.TYPE))
                                field.setLong(this, yml.getLong(path));

                            // Short
                            else if (field.getType().equals(Short.TYPE))
                                field.setShort(this, (short) yml.getInt(path));

                            // Boolean
                            else if (field.getType().equals(Boolean.TYPE))
                                field.setBoolean(this, yml.getBoolean(path));

                            // ItemStack
                            else if (field.getType().equals(ItemStack.class))
                                field.set(this, yml.getItemStack(path));

                            // String
                            else if (field.getType().equals(String.class))
                                field.set(this, yml.getString(path));
                            else
                                throw new IllegalArgumentException("Cannot use type "
                                        + field.getType().getSimpleName() + " for AutoConfiguration"); //$NON-NLS-1$
                        }
                    }
                }

                onPostLoad();
            } else {
                Bukkit.getLogger().log(Level.INFO, "Unable to create file: " + mFile.toString());
            }
        } else {
            Bukkit.getLogger().log(Level.INFO, "Unable to create file: " + mFile.getParentFile().toString());
        }
        return true;
    } catch (IOException | InvalidConfigurationException | IllegalAccessException
            | IllegalArgumentException e) {
        e.printStackTrace();
        return false;
    }
}

From source file:org.hyperic.lather.util.Latherize.java

public void latherize(boolean xDocletStyle, String outPackage, Class fClass, OutputStream os)
        throws LatherizeException, IOException {
    final String INDENT = "        ";
    PrintWriter pWriter;/*from w w  w . j  av a2  s  . com*/
    DynaProperty[] dProps;
    WrapDynaBean dBean;
    DynaClass dClass;
    Object beanInstance;
    String className, lClassName;

    try {
        beanInstance = fClass.newInstance();
    } catch (IllegalAccessException exc) {
        throw new LatherizeException("Illegal access trying to create " + "new instance");
    } catch (InstantiationException exc) {
        throw new LatherizeException("Unable to instantiate: " + exc.getMessage());
    }

    dBean = new WrapDynaBean(beanInstance);
    dClass = dBean.getDynaClass();
    dProps = dClass.getDynaProperties();

    pWriter = new PrintWriter(os);

    className = fClass.getName();
    className = className.substring(className.lastIndexOf(".") + 1);
    lClassName = "Lather" + className;

    pWriter.println("package " + outPackage + ";");
    pWriter.println();
    pWriter.println("import " + LatherValue.class.getName() + ";");
    pWriter.println("import " + LatherRemoteException.class.getName() + ";");
    pWriter.println("import " + LatherKeyNotFoundException.class.getName() + ";");
    pWriter.println("import " + fClass.getName() + ";");
    pWriter.println();
    pWriter.println("public class " + lClassName);
    pWriter.println("    extends LatherValue");
    pWriter.println("{");
    for (int i = 0; i < dProps.length; i++) {
        pWriter.print("    ");
        if (!this.isLatherStyleProp(dProps[i])) {
            pWriter.print("// ");
        }

        pWriter.println("private static final String " + this.makePropVar(dProps[i]) + " = \""
                + dProps[i].getName() + "\";");
    }

    pWriter.println();
    pWriter.println("    public " + lClassName + "(){");
    pWriter.println("        super();");
    pWriter.println("    }");
    pWriter.println();
    pWriter.println("    public " + lClassName + "(" + className + " v){");
    pWriter.println("        super();");
    pWriter.println();
    for (int i = 0; i < dProps.length; i++) {
        String propVar = this.makePropVar(dProps[i]);
        String getter = "v." + this.makeGetter(dProps[i]) + "()";

        if (!this.isLatherStyleProp(dProps[i])) {
            continue;
        }

        if (xDocletStyle) {
            String lName;

            lName = dProps[i].getName();
            lName = lName.substring(0, 1).toLowerCase() + lName.substring(1);
            pWriter.println(INDENT + "if(v." + lName + "HasBeenSet()){");
            pWriter.print("    ");
        }

        if (dProps[i].getType().equals(String.class)) {
            pWriter.println(INDENT + "this.setStringValue(" + propVar + ", " + getter + ");");
        } else if (dProps[i].getType().equals(Integer.TYPE)) {
            pWriter.println(INDENT + "this.setIntValue(" + propVar + ", " + getter + ");");
        } else if (dProps[i].getType().equals(Integer.class)) {
            pWriter.println(INDENT + "this.setIntValue(" + propVar + ", " + getter + ".intValue());");
        } else if (dProps[i].getType().equals(Long.TYPE)) {
            pWriter.println(INDENT + "this.setDoubleValue(" + propVar + ", (double)" + getter + ");");
        } else if (dProps[i].getType().equals(Long.class)) {
            pWriter.println(
                    INDENT + "this.setDoubleValue(" + propVar + ", (double)" + getter + ".longValue());");
        } else if (dProps[i].getType().equals(Boolean.TYPE)) {
            pWriter.println(INDENT + "this.setIntValue(" + propVar + ", " + getter + " ? 1 : 0);");
        } else if (dProps[i].getType().equals(Boolean.class)) {
            pWriter.println(
                    INDENT + "this.setIntValue(" + propVar + ", " + getter + ".booleanValue() ? 1 : 0);");
        } else if (dProps[i].getType().equals(Double.TYPE)) {
            pWriter.println(INDENT + "this.setDoubleValue(" + propVar + ", " + getter + ");");
        } else if (dProps[i].getType().equals(Double.class)) {
            pWriter.println(INDENT + "this.setDoubleValue(" + propVar + ", " + getter + ".doubleValue());");
        } else if (dProps[i].getType().equals(byte[].class)) {
            pWriter.println(INDENT + "this.setByteAValue(" + propVar + ", " + getter + ");");
        } else {
            pWriter.println(INDENT + "this.setObjectValue(" + "DONT KNOW HOW TO HANDLE THIS, " + getter + ");");
        }

        if (xDocletStyle) {
            pWriter.println(INDENT + "}");
            pWriter.println();
        }
    }
    pWriter.println("    }");

    pWriter.println();
    pWriter.println("    public " + className + " get" + className + "(){");
    pWriter.println(INDENT + className + " r = new " + className + "();");
    pWriter.println();
    for (int i = 0; i < dProps.length; i++) {
        String propVar = this.makePropVar(dProps[i]);
        String setter = "r." + this.makeSetter(dProps[i]) + "(";

        if (!this.isLatherStyleProp(dProps[i])) {
            continue;
        }

        if (xDocletStyle) {
            pWriter.println(INDENT + "try {");
            pWriter.print("    ");
        }

        pWriter.print(INDENT + setter);
        if (dProps[i].getType().equals(String.class)) {
            pWriter.println("this.getStringValue(" + propVar + "));");
        } else if (dProps[i].getType().equals(Integer.TYPE)) {
            pWriter.println("this.getIntValue(" + propVar + "));");
        } else if (dProps[i].getType().equals(Integer.class)) {
            pWriter.println("new Integer(this.getIntValue(" + propVar + ")));");
        } else if (dProps[i].getType().equals(Long.TYPE)) {
            pWriter.println("(long)this.getDoubleValue(" + propVar + "));");
        } else if (dProps[i].getType().equals(Long.class)) {
            pWriter.println("new Long((long)this.getDoubleValue(" + propVar + ")));");
        } else if (dProps[i].getType().equals(Boolean.TYPE)) {
            pWriter.println("this.getIntValue(" + propVar + ") == 1 ? " + "true : false);");
        } else if (dProps[i].getType().equals(Boolean.class)) {
            pWriter.println("this.getIntValue(" + propVar + ") == 1 ? " + "Boolean.TRUE : Boolean.FALSE);");
        } else if (dProps[i].getType().equals(Double.TYPE)) {
            pWriter.println("this.getDoubleValue(" + propVar + "));");
        } else if (dProps[i].getType().equals(Double.class)) {
            pWriter.println("new Double(this.getDoubleValue(" + propVar + ")));");
        } else if (dProps[i].getType().equals(byte[].class)) {
            pWriter.println("this.getByteAValue(" + propVar + "));");
        } else {
            pWriter.println("DONT KNOW HOW TO HANDLE " + propVar + "));");
        }

        if (xDocletStyle) {
            pWriter.println(INDENT + "} catch(LatherKeyNotFoundException " + "exc){}");
            pWriter.println();
        }
    }

    pWriter.println(INDENT + "return r;");
    pWriter.println("    }");
    pWriter.println();
    pWriter.println("    protected void validate()");
    pWriter.println("        throws LatherRemoteException");
    pWriter.println("    {");
    if (!xDocletStyle) {
        pWriter.println("        try { ");
        pWriter.println("            this.get" + className + "();");
        pWriter.println("        } catch(LatherKeyNotFoundException e){");
        pWriter.println("            throw new LatherRemoteException(\"" + "All values not set\");");
        pWriter.println("        }");
    }
    pWriter.println("    }");
    pWriter.println("}");
    pWriter.flush();
}

From source file:org.gradle.internal.reflect.JavaReflectionUtil.java

public static Class<?> getWrapperTypeForPrimitiveType(Class<?> type) {
    if (type == Character.TYPE) {
        return Character.class;
    } else if (type == Boolean.TYPE) {
        return Boolean.class;
    } else if (type == Long.TYPE) {
        return Long.class;
    } else if (type == Integer.TYPE) {
        return Integer.class;
    } else if (type == Short.TYPE) {
        return Short.class;
    } else if (type == Byte.TYPE) {
        return Byte.class;
    } else if (type == Float.TYPE) {
        return Float.class;
    } else if (type == Double.TYPE) {
        return Double.class;
    }//from w  ww.  j  a  v a2  s  .  c  om
    throw new IllegalArgumentException(
            String.format("Don't know the wrapper type for primitive type %s.", type));
}

From source file:org.briljantframework.data.resolver.Resolve.java

private static Resolver<Integer> initializeIntegerResolver() {
    Resolver<Integer> resolver = new Resolver<>(Integer.class);
    resolver.put(Number.class, Number::intValue);
    resolver.put(Double.class, Number::intValue);
    resolver.put(Double.TYPE, Number::intValue);
    resolver.put(Float.class, Number::intValue);
    resolver.put(Float.TYPE, Number::intValue);
    resolver.put(Long.class, Number::intValue);
    resolver.put(Long.TYPE, Number::intValue);
    resolver.put(Integer.class, Number::intValue);
    resolver.put(Integer.TYPE, Number::intValue);
    resolver.put(Short.class, Number::intValue);
    resolver.put(Short.TYPE, Number::intValue);
    resolver.put(Byte.class, Number::intValue);
    resolver.put(Byte.TYPE, Number::intValue);
    resolver.put(String.class, s -> {
        try {/*from   w ww.j a  v  a2  s .c o  m*/
            return NumberUtils.createNumber(s).intValue();
        } catch (Exception e) {
            return null;
        }
    });
    return resolver;
}