java.lang.Double.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(391)

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

Double.<init>介绍

[英]Constructs a new Double with the specified primitive double value.
[中]使用指定的原语Double值构造新的Double。

代码示例

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

/**
 * Returns a Double instance representing the specified double.
 * Double.valueOf was added in JDK 1.5.
 *
 * @param b a double value.
 * @return a Byte instance representing b.
 */
protected static Double valueOf(final double b) {
  return new Double(b);
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * <p>Returns the minimum number in this range.</p>
 *
 * @return the minimum number in this range
 */
public Number getMinimumNumber() {
  if (minObject == null) {
    minObject = new Double(min);            
  }
  return minObject;
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * <p>Returns the maximum number in this range.</p>
 *
 * @return the maximum number in this range
 */
public Number getMaximumNumber() {
  if (maxObject == null) {
    maxObject = new Double(max);            
  }
  return maxObject;
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * Gets the value as a Double instance.
 * 
 * @return the value as a Double, never null
 */
public Object getValue() {
  return new Double(this.value);
}

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

@Override
  public Object decode(Object jv) {
    if (jv instanceof Number) {
      return new Double(((Number) jv).doubleValue());
    }
    return (Double) null;
  }
};

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

@Override
  public Object decode(Object jv) {
    if (jv instanceof Number) {
      return new Double(((Number) jv).doubleValue());
    }
    return (Double) null;
  }
};

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

@Override
public Object instantiate(Class objectClass, FSTObjectInput in, FSTClazzInfo serializationInfo, FSTClazzInfo.FSTFieldInfo referencee, int streamPosition) throws Exception {
  Object res = new Double(in.readDouble());
  return res;
}

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

public boolean valid(Double ratio) {
    return new Double(42).equals(ratio);
  }
}

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

@Generates
private Double generateDoubleObject() {
 return new Double(generateDouble());
}

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

@Override
  State next(int ch) {
    if (_isFirst)
      _value = (byte) ch;
    else
      _value = 256 * _value + (ch & 0xff);
    _isFirst = false;
    if (++_length == 4) {
      Double value = new Double(_value);
      if (_next.isShift(value))
        return _next.shift(value);
      else {
        printObject(value.toString());
        return _next;
      }
    } else
      return this;
  }
}

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

public void testHashCode() throws Exception {
 int h1 = Objects.hashCode(1, "two", 3.0);
 int h2 = Objects.hashCode(new Integer(1), new String("two"), new Double(3.0));
 // repeatable
 assertEquals(h1, h2);
 // These don't strictly need to be true, but they're nice properties.
 assertTrue(Objects.hashCode(1, 2, null) != Objects.hashCode(1, 2));
 assertTrue(Objects.hashCode(1, 2, null) != Objects.hashCode(1, null, 2));
 assertTrue(Objects.hashCode(1, null, 2) != Objects.hashCode(1, 2));
 assertTrue(Objects.hashCode(1, 2, 3) != Objects.hashCode(3, 2, 1));
 assertTrue(Objects.hashCode(1, 2, 3) != Objects.hashCode(2, 3, 1));
}

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

@Test
@Deprecated
public void hashCodeWithDouble() {
  double dbl = 9830.43;
  int expected = (new Double(dbl)).hashCode();
  assertEquals(expected, ObjectUtils.hashCode(dbl));
}

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

@Test
public void testMathOperatorDivide_ConvertToDouble() {
  evaluateAndAskForReturnType("8/4", new Double(2.0), Double.class);
}

代码示例来源:origin: greenrobot/EventBus

@Test
  public void testGenericEventAndSubscriber_Subclass() {
    GenericFloatEventSubscriber genericSubscriber = new GenericFloatEventSubscriber();
    eventBus.register(genericSubscriber);
    eventBus.post(new Float(42));
    eventBus.post(new Double(77));
    assertEventCount(2);
    eventBus.post("Not the same base type");
    assertEventCount(2);
  }
}

代码示例来源:origin: greenrobot/EventBus

@Test
public void testGenericEventAndSubscriber_BaseType() {
  GenericNumberEventSubscriber<Float> genericSubscriber = new GenericNumberEventSubscriber<>();
  eventBus.register(genericSubscriber);
  eventBus.post(new Float(42));
  eventBus.post(new Double(23));
  assertEventCount(2);
  eventBus.post("Not the same base type");
  assertEventCount(2);
}

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

@Test
public void testSettingGenericPropertyWithReadOnlyInterface() {
  Bar bar = new Bar();
  BeanWrapper bw = new BeanWrapperImpl(bar);
  bw.setPropertyValue("version", "10");
  assertEquals(new Double(10.0), bar.getVersion());
}

代码示例来源:origin: greenrobot/EventBus

@Test
  public void testGenericEventAndSubscriber_Subclass() {
    GenericFloatEventSubscriber genericSubscriber = new GenericFloatEventSubscriber();
    eventBus.register(genericSubscriber);
    eventBus.post(new Float(42));
    eventBus.post(new Double(77));
    assertEventCount(2);
    eventBus.post("Not the same base type");
    assertEventCount(2);
  }
}

代码示例来源:origin: greenrobot/EventBus

@Test
public void testGenericEventAndSubscriber_BaseType() {
  GenericNumberEventSubscriber<Float> genericSubscriber = new GenericNumberEventSubscriber<>();
  eventBus.register(genericSubscriber);
  eventBus.post(new Float(42));
  eventBus.post(new Double(23));
  assertEventCount(2);
  eventBus.post("Not the same base type");
  assertEventCount(2);
}

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

@Test
public void testDynamicMatchingProxy() {
  String expression = "execution(void org.springframework.tests.sample.beans.TestBean.setSomeNumber(Number)) && args(Double)";
  CallCountingInterceptor interceptor = new CallCountingInterceptor();
  TestBean testBean = getAdvisedProxy(expression, interceptor);
  assertEquals("Calls should be 0", 0, interceptor.getCount());
  testBean.setSomeNumber(new Double(30));
  assertEquals("Calls should be 1", 1, interceptor.getCount());
  testBean.setSomeNumber(new Integer(90));
  assertEquals("Calls should be 1", 1, interceptor.getCount());
}

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

@Test
public void testMatchWithArgs() throws Exception {
  String expression = "execution(void org.springframework.tests.sample.beans.TestBean.setSomeNumber(Number)) && args(Double)";
  Pointcut pointcut = getPointcut(expression);
  ClassFilter classFilter = pointcut.getClassFilter();
  MethodMatcher methodMatcher = pointcut.getMethodMatcher();
  assertMatchesTestBeanClass(classFilter);
  // not currently testable in a reliable fashion
  //assertDoesNotMatchStringClass(classFilter);
  assertTrue("Should match with setSomeNumber with Double input",
      methodMatcher.matches(setSomeNumber, TestBean.class, new Double(12)));
  assertFalse("Should not match setSomeNumber with Integer input",
      methodMatcher.matches(setSomeNumber, TestBean.class, new Integer(11)));
  assertFalse("Should not match getAge", methodMatcher.matches(getAge, TestBean.class));
  assertTrue("Should be a runtime match", methodMatcher.isRuntime());
}

相关文章