List of usage examples for java.lang Float TYPE
Class TYPE
To view the source code for java.lang Float TYPE.
Click Source Link
From source file:com.aol.one.patch.DefaultPatcher.java
private List<MethodData> generateMethodData(List<String> methodNames, JsonNode valueNode) { List<MethodData> dataList = new ArrayList<>(); if (valueNode.isTextual()) { for (String methodName : methodNames) { dataList.add(new MethodData(methodName, String.class, valueNode.asText())); }//from w ww .ja va 2s . c om } else if (valueNode.isNumber()) { for (String methodName : methodNames) { if (valueNode.isIntegralNumber()) { dataList.add(new MethodData(methodName, Long.TYPE, valueNode.asLong())); dataList.add(new MethodData(methodName, Long.class, valueNode.asLong())); dataList.add(new MethodData(methodName, Integer.TYPE, valueNode.asInt())); dataList.add(new MethodData(methodName, Integer.class, valueNode.asInt())); dataList.add(new MethodData(methodName, Short.TYPE, (short) valueNode.asInt())); dataList.add(new MethodData(methodName, Short.class, (short) valueNode.asInt())); } else { dataList.add(new MethodData(methodName, Double.TYPE, valueNode.asDouble())); dataList.add(new MethodData(methodName, Double.class, valueNode.asDouble())); dataList.add(new MethodData(methodName, Float.TYPE, valueNode.asDouble())); dataList.add(new MethodData(methodName, Float.class, valueNode.asDouble())); } } } else if (valueNode.isBoolean()) { for (String methodName : methodNames) { dataList.add(new MethodData(methodName, Boolean.TYPE, valueNode.asBoolean())); dataList.add(new MethodData(methodName, Boolean.class, valueNode.asBoolean())); } } // default for (String methodName : methodNames) { dataList.add(new MethodData(methodName, JsonNode.class, valueNode)); } return dataList; }
From source file:com.ryan.ryanreader.jsonwrap.JsonBufferedObject.java
public void populateObject(final Object o) throws InterruptedException, IOException, IllegalArgumentException, InstantiationException, NoSuchMethodException, InvocationTargetException { if (join() != Status.LOADED) { throwFailReasonException();//from w w w . j a va 2s. co m } final Field[] objectFields = o.getClass().getFields(); try { for (final Field objectField : objectFields) { if ((objectField.getModifiers() & Modifier.TRANSIENT) != 0) { continue; } final JsonValue val; if (properties.containsKey(objectField.getName())) { val = properties.get(objectField.getName()); } else if (objectField.getName().startsWith("_json_")) { val = properties.get(objectField.getName().substring("_json_".length())); } else { val = null; } if (val == null) { continue; } objectField.setAccessible(true); final Class<?> fieldType = objectField.getType(); if (fieldType == Long.class || fieldType == Long.TYPE) { objectField.set(o, val.asLong()); } else if (fieldType == Double.class || fieldType == Double.TYPE) { objectField.set(o, val.asDouble()); } else if (fieldType == Integer.class || fieldType == Integer.TYPE) { objectField.set(o, val.isNull() ? null : val.asLong().intValue()); } else if (fieldType == Float.class || fieldType == Float.TYPE) { objectField.set(o, val.isNull() ? null : val.asDouble().floatValue()); } else if (fieldType == Boolean.class || fieldType == Boolean.TYPE) { objectField.set(o, val.asBoolean()); } else if (fieldType == String.class) { objectField.set(o, val.asString()); } else if (fieldType == JsonBufferedArray.class) { objectField.set(o, val.asArray()); } else if (fieldType == JsonBufferedObject.class) { objectField.set(o, val.asObject()); } else if (fieldType == JsonValue.class) { objectField.set(o, val); } else if (fieldType == Object.class) { final Object result; switch (val.getType()) { case BOOLEAN: result = val.asBoolean(); break; case INTEGER: result = val.asLong(); break; case STRING: result = val.asString(); break; case FLOAT: result = val.asDouble(); break; default: result = val; } objectField.set(o, result); } else { objectField.set(o, val.asObject(fieldType)); } } } catch (IllegalAccessException e) { throw new RuntimeException(e); } }
From source file:jp.terasoluna.fw.web.struts.reset.ResetterImpl.java
/** * ANVtH?[wv?peBZbg?B//from w w w . j a v a 2 s . co m * v?peB^boolean^?ABoolean^??false??B * v~eBu^bp?[^???A0??B * v?peB^bp?[^OObject^??null??B<br> * ??A?entrynulln?B * * @param form ?NGXggpANVtH?[ * @param entry Zbg?v?peB?lGg * @throws PropertyAccessException v?peBl?s?? */ protected void resetValue(FormEx form, Entry<String, Object> entry) { if (log.isDebugEnabled()) { log.debug("resetValue(" + form + ", " + entry.getKey() + ") called."); } String propName = entry.getKey(); try { Object value = entry.getValue(); if (value == null) { return; } Class type = null; type = value.getClass(); if (type != null) { // ^???B if (type == Boolean.TYPE || type == Boolean.class) { BeanUtil.setBeanProperty(form, propName, Boolean.FALSE); } else if (type == Byte.TYPE || type == Byte.class) { BeanUtil.setBeanProperty(form, propName, new Byte((byte) 0)); } else if (type == Character.TYPE || type == Character.class) { BeanUtil.setBeanProperty(form, propName, new Character((char) 0)); } else if (type == Double.TYPE || type == Double.class) { BeanUtil.setBeanProperty(form, propName, new Double(0.0)); } else if (type == Float.TYPE || type == Float.class) { BeanUtil.setBeanProperty(form, propName, new Float((float) 0.0)); } else if (type == Integer.TYPE || type == Integer.class) { BeanUtil.setBeanProperty(form, propName, new Integer(0)); } else if (type == Long.TYPE || type == Long.class) { BeanUtil.setBeanProperty(form, propName, new Long(0)); } else if (type == Short.TYPE || type == Short.class) { BeanUtil.setBeanProperty(form, propName, new Short((short) 0)); } else { // v~eBu^?Abp?[^??null? BeanUtil.setBeanProperty(form, propName, null); } } } catch (PropertyAccessException e) { log.error("cannot access property " + form + "." + propName, e); } }
From source file:org.quantumbadger.redreader.jsonwrap.JsonBufferedObject.java
public void populateObject(final Object o) throws InterruptedException, IOException, IllegalArgumentException, InstantiationException, NoSuchMethodException, InvocationTargetException { if (join() != STATUS_LOADED) { throwFailReasonException();/*from w ww. j a v a 2 s . c o m*/ } final Field[] objectFields = o.getClass().getFields(); try { for (final Field objectField : objectFields) { if ((objectField.getModifiers() & Modifier.TRANSIENT) != 0) { continue; } final JsonValue val; if (properties.containsKey(objectField.getName())) { val = properties.get(objectField.getName()); } else if (objectField.getName().startsWith("_json_")) { val = properties.get(objectField.getName().substring("_json_".length())); } else { val = null; } if (val == null) { continue; } objectField.setAccessible(true); final Class<?> fieldType = objectField.getType(); if (fieldType == Long.class || fieldType == Long.TYPE) { objectField.set(o, val.asLong()); } else if (fieldType == Double.class || fieldType == Double.TYPE) { objectField.set(o, val.asDouble()); } else if (fieldType == Integer.class || fieldType == Integer.TYPE) { objectField.set(o, val.isNull() ? null : val.asLong().intValue()); } else if (fieldType == Float.class || fieldType == Float.TYPE) { objectField.set(o, val.isNull() ? null : val.asDouble().floatValue()); } else if (fieldType == Boolean.class || fieldType == Boolean.TYPE) { objectField.set(o, val.asBoolean()); } else if (fieldType == String.class) { objectField.set(o, val.asString()); } else if (fieldType == JsonBufferedArray.class) { objectField.set(o, val.asArray()); } else if (fieldType == JsonBufferedObject.class) { objectField.set(o, val.asObject()); } else if (fieldType == JsonValue.class) { objectField.set(o, val); } else if (fieldType == Object.class) { final Object result; switch (val.getType()) { case JsonValue.TYPE_BOOLEAN: result = val.asBoolean(); break; case JsonValue.TYPE_INTEGER: result = val.asLong(); break; case JsonValue.TYPE_STRING: result = val.asString(); break; case JsonValue.TYPE_FLOAT: result = val.asDouble(); break; default: result = val; } objectField.set(o, result); } else { objectField.set(o, val.asObject(fieldType)); } } } catch (IllegalAccessException e) { throw new RuntimeException(e); } }
From source file:com.netspective.commons.lang.ValueBeanGeneratorClassLoader.java
/** * Convert runtime java.lang.Class to BCEL Type object. * * @param cl Java class/*from w ww.j ava 2 s . c o m*/ * * @return corresponding Type object */ public static Type getBCELType(java.lang.Class cl) { if (cl == null) { throw new IllegalArgumentException("Class must not be null"); } /* That's an amzingly easy case, because getName() returns * the signature. That's what we would have liked anyway. */ if (cl.isArray()) { return Type.getType(cl.getName()); } else if (cl.isPrimitive()) { if (cl == Integer.TYPE) { return Type.INT; } else if (cl == Void.TYPE) { return Type.VOID; } else if (cl == Double.TYPE) { return Type.DOUBLE; } else if (cl == Float.TYPE) { return Type.FLOAT; } else if (cl == Boolean.TYPE) { return Type.BOOLEAN; } else if (cl == Byte.TYPE) { return Type.BYTE; } else if (cl == Short.TYPE) { return Type.SHORT; } else if (cl == Long.TYPE) { return Type.LONG; } else if (cl == Character.TYPE) { return Type.CHAR; } else { throw new IllegalStateException("Ooops, what primitive type is " + cl); } } else { // "Real" class return new ObjectType(cl.getName()); } }
From source file:org.openTwoFactor.clientExt.net.sf.ezmorph.bean.MorphDynaBean.java
protected boolean isDynaAssignable(Class dest, Class src) { boolean assignable = dest.isAssignableFrom(src); if (assignable) { return true; }//from w ww . ja v a 2 s . c o m assignable = (dest == Boolean.TYPE && src == Boolean.class) ? true : assignable; assignable = (dest == Byte.TYPE && src == Byte.class) ? true : assignable; assignable = (dest == Character.TYPE && src == Character.class) ? true : assignable; assignable = (dest == Short.TYPE && src == Short.class) ? true : assignable; assignable = (dest == Integer.TYPE && src == Integer.class) ? true : assignable; assignable = (dest == Long.TYPE && src == Long.class) ? true : assignable; assignable = (dest == Float.TYPE && src == Float.class) ? true : assignable; assignable = (dest == Double.TYPE && src == Double.class) ? true : assignable; if (src == Double.TYPE || Double.class.isAssignableFrom(src)) { assignable = (isByte(dest) || isShort(dest) || isInteger(dest) || isLong(dest) || isFloat(dest)) ? true : assignable; } if (src == Float.TYPE || Float.class.isAssignableFrom(src)) { assignable = (isByte(dest) || isShort(dest) || isInteger(dest) || isLong(dest)) ? true : assignable; } if (src == Long.TYPE || Long.class.isAssignableFrom(src)) { assignable = (isByte(dest) || isShort(dest) || isInteger(dest)) ? true : assignable; } if (src == Integer.TYPE || Integer.class.isAssignableFrom(src)) { assignable = (isByte(dest) || isShort(dest)) ? true : assignable; } if (src == Short.TYPE || Short.class.isAssignableFrom(src)) { assignable = (isByte(dest)) ? true : assignable; } return assignable; }
From source file:com.adobe.acs.commons.data.Variant.java
@SuppressWarnings("squid:S3776") public <T> T asType(Class<T> type) { if (type == Byte.TYPE || type == Byte.class) { return (T) apply(toLong(), Long::byteValue); } else if (type == Integer.TYPE || type == Integer.class) { return (T) apply(toLong(), Long::intValue); } else if (type == Long.TYPE || type == Long.class) { return (T) toLong(); } else if (type == Short.TYPE || type == Short.class) { return (T) apply(toLong(), Long::shortValue); } else if (type == Float.TYPE || type == Float.class) { return (T) apply(toDouble(), Double::floatValue); } else if (type == Double.TYPE || type == Double.class) { return (T) toDouble(); } else if (type == Boolean.TYPE || type == Boolean.class) { return (T) toBoolean(); } else if (type == String.class) { return (T) toString(); } else if (type == Date.class) { return (T) toDate(); } else if (type == Instant.class) { return (T) toDate().toInstant(); } else if (type == Calendar.class) { Calendar c = Calendar.getInstance(); c.setTime(toDate());//from w ww . j a v a2 s .c o m return (T) c; } else { return null; } }
From source file:org.romaframework.core.schema.SchemaHelper.java
public static Object assignValueToLiteral(String v, Class<?> type) { Object value;/*ww w . ja v a 2s. c om*/ if (v.length() == 0) { value = null; } else { if (type.equals(Integer.class) || type.equals(Integer.TYPE)) { value = Integer.parseInt(v); } else if (type.equals(Long.class) || type.equals(Long.TYPE)) { value = Long.parseLong(v); } else if (type.equals(Short.class) || type.equals(Short.TYPE)) { value = Short.parseShort(v); } else if (type.equals(Boolean.class) || type.equals(Boolean.TYPE)) { value = Boolean.parseBoolean(v); } else if (type.equals(Float.class) || type.equals(Float.TYPE)) { value = Float.parseFloat(v); } else if (type.equals(Double.class) || type.equals(Double.TYPE)) { value = Double.parseDouble(v); } else if (type.equals(Byte.class) || type.equals(Byte.TYPE)) { value = Byte.parseByte(v); } else if (type.equals(Character.class) || type.equals(Character.TYPE)) { value = v.charAt(0); } else { value = v; } } return value; }
From source file:us.mn.state.health.lims.testanalyte.form.TestAnalyteTestResultActionForm.java
/** * <p>/*from w w w .ja va2 s. c o m*/ * Return the value of a simple property with the specified name. * </p> * * @param name * Name of the property whose value is to be retrieved * * @exception IllegalArgumentException * if there is no property of the specified name * @exception NullPointerException * if the type specified for the property is invalid */ public Object get(String name) { // Return any non-null value for the specified property Object value = dynaValues.get(name); //System.out.println("I am in get(String name) " + name + " " + value); if (value != null) { return (value); } // Return a null value for a non-primitive property Class type = getDynaProperty(name).getType(); if (type == null) { throw new NullPointerException("The type for property " + name + " is invalid"); } 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(0.0)); } else if (type == Float.TYPE) { return (new Float((float) 0.0)); } else if (type == Integer.TYPE) { return (new Integer(0)); } else if (type == Long.TYPE) { return (new Long(0)); } else if (type == Short.TYPE) { return (new Short((short) 0)); } else { return (null); } }
From source file:com.opengamma.language.definition.JavaTypeInfo.java
private static Class<?> findClass(final String className) throws ClassNotFoundException { if ("boolean".equals(className)) { return Boolean.TYPE; } else if ("char".equals(className)) { return Character.TYPE; } else if ("double".equals(className)) { return Double.TYPE; } else if ("float".equals(className)) { return Float.TYPE; } else if ("int".equals(className)) { return Integer.TYPE; } else if ("long".equals(className)) { return Long.TYPE; } else if ("short".equals(className)) { return Short.TYPE; } else {/* ww w . j a v a2s .c o m*/ return Class.forName(className); } }