java.lang.Float.floatValue()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(205)

本文整理了Java中java.lang.Float.floatValue()方法的一些代码示例,展示了Float.floatValue()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Float.floatValue()方法的具体详情如下:
包路径:java.lang.Float
类名称:Float
方法名:floatValue

Float.floatValue介绍

[英]Gets the primitive value of this float.
[中]获取此浮点的基元值。

代码示例

代码示例来源:origin: apache/incubator-dubbo

public static float unboxed(Float v) {
  return v == null ? 0 : v.floatValue();
}

代码示例来源:origin: apache/incubator-dubbo

public static float unboxed(Float v) {
  return v == null ? 0 : v.floatValue();
}

代码示例来源:origin: spring-projects/spring-framework

public float getFloatProperty(String name) throws JMSException {
  Object value = this.properties.get(name);
  return (value instanceof Float) ? ((Float) value).floatValue() : 0;
}

代码示例来源:origin: libgdx/libgdx

public void setValues (List values) {
  super.setValues(values);
  for (Iterator iter = values.iterator(); iter.hasNext();) {
    Value value = (Value)iter.next();
    if (value.getName().equals("Wavelength")) {
      wavelength = ((Float)value.getObject()).floatValue();
    } else if (value.getName().equals("Amplitude")) {
      amplitude = ((Float)value.getObject()).floatValue();
    }
  }
}

代码示例来源:origin: libgdx/libgdx

public void setValues (List values) {
  super.setValues(values);
  for (Iterator iter = values.iterator(); iter.hasNext();) {
    Value value = (Value)iter.next();
    if (value.getName().equals("Detail")) {
      detail = ((Float)value.getObject()).floatValue();
    } else if (value.getName().equals("Amplitude")) {
      amplitude = ((Float)value.getObject()).floatValue();
    }
  }
}

代码示例来源:origin: libgdx/libgdx

public void setValues (List values) {
  super.setValues(values);
  for (Iterator iter = values.iterator(); iter.hasNext();) {
    Value value = (Value)iter.next();
    if (value.getName().equals("Detail")) {
      detail = ((Float)value.getObject()).floatValue();
    } else if (value.getName().equals("Amplitude")) {
      amplitude = ((Float)value.getObject()).floatValue();
    }
  }
}

代码示例来源:origin: libgdx/libgdx

public void setValues (List values) {
  super.setValues(values);
  for (Iterator iter = values.iterator(); iter.hasNext();) {
    Value value = (Value)iter.next();
    if (value.getName().equals("Wavelength")) {
      wavelength = ((Float)value.getObject()).floatValue();
    } else if (value.getName().equals("Amplitude")) {
      amplitude = ((Float)value.getObject()).floatValue();
    }
  }
}

代码示例来源:origin: spring-projects/spring-framework

public Object addOne(ProceedingJoinPoint pjp, Float value) throws Throwable {
  float fv = value.floatValue();
  return pjp.proceed(new Object[] {new Float(fv + 1.0F)});
}

代码示例来源:origin: libgdx/libgdx

public void setValues (List values) {
    for (Iterator iter = values.iterator(); iter.hasNext();) {
      Value value = (Value)iter.next();
      if (value.getName().equals("Color")) {
        color = (Color)value.getObject();
      } else if (value.getName().equals("Width")) {
        width = ((Float)value.getObject()).floatValue();
      } else if (value.getName().equals("Join")) {
        join = Integer.parseInt((String)value.getObject());
      }
    }
  }
}

代码示例来源:origin: libgdx/libgdx

public void setValues (List values) {
    for (Iterator iter = values.iterator(); iter.hasNext();) {
      Value value = (Value)iter.next();
      if (value.getName().equals("Color")) {
        color = (Color)value.getObject();
      } else if (value.getName().equals("Width")) {
        width = ((Float)value.getObject()).floatValue();
      } else if (value.getName().equals("Join")) {
        join = Integer.parseInt((String)value.getObject());
      }
    }
  }
}

代码示例来源:origin: alibaba/fastjson

public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
  SerializeWriter out = serializer.out;
  
  if (object == null) {
    out.writeNull(SerializerFeature.WriteNullNumberAsZero);
    return;
  }
  float floatValue = ((Float) object).floatValue();
  if (decimalFormat != null) {
    String floatText = decimalFormat.format(floatValue);
    out.write(floatText);
  } else {
    out.writeFloat(floatValue, true);
  }
}

代码示例来源:origin: spring-projects/spring-framework

public void captureFloatArgument(JoinPoint tjp, float arg) {
  float tjpArg = ((Float) tjp.getArgs()[0]).floatValue();
  if (Math.abs(tjpArg - arg) > 0.000001) {
    throw new IllegalStateException(
        "argument is '" + arg + "', " +
        "but args array has '" + tjpArg + "'"
        );
  }
  this.lastBeforeFloatValue = arg;
}

代码示例来源:origin: prestodb/presto

/**
 * Alternative method that we need to avoid bumping into NPE issues
 * with auto-unboxing.
 *
 * @return This array node, to allow chaining
 */
public ArrayNode add(Float value) {
  if (value == null) {
    return addNull();
  }
  return _add(numberNode(value.floatValue()));
}

代码示例来源:origin: prestodb/presto

/**
 * Alternative method that we need to avoid bumping into NPE issues
 * with auto-unboxing.
 *
 * @return This array node, to allow chaining
 */
public ArrayNode insert(int index, Float value) {
  if (value == null) {
    return insertNull(index);
  }
  return _insert(index, numberNode(value.floatValue()));
}

代码示例来源:origin: prestodb/presto

/**
 * Alternative method that we need to avoid bumping into NPE issues
 * with auto-unboxing.
 * 
 * @return This node (to allow chaining)
 */
public ObjectNode put(String fieldName, Float v) {
  return _put(fieldName, (v == null) ? nullNode()
      : numberNode(v.floatValue()));
}

代码示例来源:origin: google/guava

public void testGetDefaultValue() {
  assertEquals(false, Defaults.defaultValue(boolean.class).booleanValue());
  assertEquals('\0', Defaults.defaultValue(char.class).charValue());
  assertEquals(0, Defaults.defaultValue(byte.class).byteValue());
  assertEquals(0, Defaults.defaultValue(short.class).shortValue());
  assertEquals(0, Defaults.defaultValue(int.class).intValue());
  assertEquals(0, Defaults.defaultValue(long.class).longValue());
  assertEquals(0.0f, Defaults.defaultValue(float.class).floatValue());
  assertEquals(0.0d, Defaults.defaultValue(double.class).doubleValue());
  assertNull(Defaults.defaultValue(void.class));
  assertNull(Defaults.defaultValue(String.class));
 }
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void testCustomEditorWithBeanReference() {
  DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
  lbf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() {
    @Override
    public void registerCustomEditors(PropertyEditorRegistry registry) {
      NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
      registry.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, nf, true));
    }
  });
  MutablePropertyValues pvs = new MutablePropertyValues();
  pvs.add("myFloat", new RuntimeBeanReference("myFloat"));
  RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
  bd.setPropertyValues(pvs);
  lbf.registerBeanDefinition("testBean", bd);
  lbf.registerSingleton("myFloat", "1,1");
  TestBean testBean = (TestBean) lbf.getBean("testBean");
  assertTrue(testBean.getMyFloat().floatValue() == 1.1f);
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void testCustomEditor() {
  DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
  lbf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() {
    @Override
    public void registerCustomEditors(PropertyEditorRegistry registry) {
      NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
      registry.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, nf, true));
    }
  });
  MutablePropertyValues pvs = new MutablePropertyValues();
  pvs.add("myFloat", "1,1");
  RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
  bd.setPropertyValues(pvs);
  lbf.registerBeanDefinition("testBean", bd);
  TestBean testBean = (TestBean) lbf.getBean("testBean");
  assertTrue(testBean.getMyFloat().floatValue() == 1.1f);
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void testCustomTypeConverterWithBeanReference() {
  DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
  NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
  lbf.setTypeConverter(new CustomTypeConverter(nf));
  MutablePropertyValues pvs = new MutablePropertyValues();
  pvs.add("myFloat", new RuntimeBeanReference("myFloat"));
  ConstructorArgumentValues cav = new ConstructorArgumentValues();
  cav.addIndexedArgumentValue(0, "myName");
  cav.addIndexedArgumentValue(1, "myAge");
  lbf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class, cav, pvs));
  lbf.registerSingleton("myFloat", "1,1");
  TestBean testBean = (TestBean) lbf.getBean("testBean");
  assertEquals("myName", testBean.getName());
  assertEquals(5, testBean.getAge());
  assertTrue(testBean.getMyFloat().floatValue() == 1.1f);
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void testCustomTypeConverter() {
  DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
  NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
  lbf.setTypeConverter(new CustomTypeConverter(nf));
  MutablePropertyValues pvs = new MutablePropertyValues();
  pvs.add("myFloat", "1,1");
  ConstructorArgumentValues cav = new ConstructorArgumentValues();
  cav.addIndexedArgumentValue(0, "myName");
  cav.addIndexedArgumentValue(1, "myAge");
  lbf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class, cav, pvs));
  TestBean testBean = (TestBean) lbf.getBean("testBean");
  assertEquals("myName", testBean.getName());
  assertEquals(5, testBean.getAge());
  assertTrue(testBean.getMyFloat().floatValue() == 1.1f);
}

相关文章