本文整理了Java中java.lang.Number.intValue()
方法的一些代码示例,展示了Number.intValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Number.intValue()
方法的具体详情如下:
包路径:java.lang.Number
类名称:Number
方法名:intValue
[英]Returns this object's value as an int. Might involve rounding and/or truncating the value, so it fits into an int.
[中]以整数形式返回此对象的值。可能需要舍入和/或截断该值,以使其适合整数。
代码示例来源:origin: apache/incubator-dubbo
@Override
public Object decode(Object jv) {
if (jv instanceof Number) {
return Integer.valueOf(((Number) jv).intValue());
}
return (Integer) null;
}
};
代码示例来源:origin: apache/incubator-dubbo
@Override
public Object decode(Object jv) throws IOException {
if (jv instanceof Number) {
return new AtomicInteger(((Number) jv).intValue());
}
return (AtomicInteger) null;
}
};
代码示例来源:origin: google/guava
@Override
public Integer apply(Number x) {
return x.intValue();
}
};
代码示例来源:origin: spring-projects/spring-framework
/**
* Set the misfire instruction via the name of the corresponding
* constant in the {@link org.quartz.CronTrigger} class.
* Default is {@code MISFIRE_INSTRUCTION_SMART_POLICY}.
* @see org.quartz.CronTrigger#MISFIRE_INSTRUCTION_FIRE_ONCE_NOW
* @see org.quartz.CronTrigger#MISFIRE_INSTRUCTION_DO_NOTHING
* @see org.quartz.Trigger#MISFIRE_INSTRUCTION_SMART_POLICY
*/
public void setMisfireInstructionName(String constantName) {
this.misfireInstruction = constants.asNumber(constantName).intValue();
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Set the system property mode by the name of the corresponding constant,
* e.g. "SYSTEM_PROPERTIES_MODE_OVERRIDE".
* @param constantName name of the constant
* @see #setSystemPropertiesMode
*/
public void setSystemPropertiesModeName(String constantName) throws IllegalArgumentException {
this.systemPropertiesMode = constants.asNumber(constantName).intValue();
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Specify the level of caching that this listener container is allowed to apply,
* in the form of the name of the corresponding constant: e.g. "CACHE_CONNECTION".
* @see #setCacheLevel
*/
public void setCacheLevelName(String constantName) throws IllegalArgumentException {
if (!constantName.startsWith("CACHE_")) {
throw new IllegalArgumentException("Only cache constants allowed");
}
setCacheLevel(constants.asNumber(constantName).intValue());
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Set the validation mode to use by name. Defaults to {@link #VALIDATION_AUTO}.
* @see #setValidationMode
*/
public void setValidationModeName(String validationModeName) {
setValidationMode(constants.asNumber(validationModeName).intValue());
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Set the transaction synchronization by the name of the corresponding constant
* in this class, e.g. "SYNCHRONIZATION_ALWAYS".
* @param constantName name of the constant
* @see #SYNCHRONIZATION_ALWAYS
*/
public final void setTransactionSynchronizationName(String constantName) {
setTransactionSynchronization(constants.asNumber(constantName).intValue());
}
代码示例来源:origin: spring-projects/spring-framework
public int execute(int intIn) {
Map<String, Integer> in = new HashMap<>();
in.put("intIn", intIn);
Map<String, Object> out = execute(in);
return ((Number) out.get("intOut")).intValue();
}
}
代码示例来源:origin: spring-projects/spring-framework
public int execute(int amount, int custid) {
Map<String, Integer> in = new HashMap<>();
in.put("amount", amount);
in.put("custid", custid);
Map<String, Object> out = execute(in);
return ((Number) out.get("newid")).intValue();
}
}
代码示例来源:origin: spring-projects/spring-framework
public int execute(int amount, int custid) {
Map<String, Object> out = execute(new Object[] { amount, custid });
return ((Number) out.get("newid")).intValue();
}
}
代码示例来源:origin: google/guava
public void testForMapWildCardWithDefault() {
Map<String, Integer> map = Maps.newHashMap();
map.put("One", 1);
map.put("Three", 3);
Number number = Double.valueOf(42);
Function<String, Number> function = Functions.forMap(map, number);
assertEquals(1, function.apply("One").intValue());
assertEquals(number, function.apply("Two"));
assertEquals(3L, function.apply("Three").longValue());
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void singleKey() {
kh.getKeyList().addAll(singletonList(singletonMap("key", 1)));
assertEquals("single key should be returned", 1, kh.getKey().intValue());
}
代码示例来源:origin: spring-projects/spring-framework
public void testNullValue(CacheableService<?> service) throws Exception {
Object key = new Object();
assertNull(service.nullValue(key));
int nr = service.nullInvocations().intValue();
assertNull(service.nullValue(key));
assertEquals(nr, service.nullInvocations().intValue());
assertNull(service.nullValue(new Object()));
assertEquals(nr + 1, service.nullInvocations().intValue());
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void singleKeyNonNumeric() {
kh.getKeyList().addAll(singletonList(singletonMap("key", "1")));
exception.expect(DataRetrievalFailureException.class);
exception.expectMessage(startsWith("The generated key is not of a supported numeric type."));
kh.getKey().intValue();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testClassNullValue() throws Exception {
Object key = new Object();
assertNull(this.ccs.nullValue(key));
int nr = this.ccs.nullInvocations().intValue();
assertNull(this.ccs.nullValue(key));
assertEquals(nr, this.ccs.nullInvocations().intValue());
assertNull(this.ccs.nullValue(new Object()));
// the check method is also cached
assertEquals(nr, this.ccs.nullInvocations().intValue());
assertEquals(nr + 1, AnnotatedClassCacheableService.nullInvocations.intValue());
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testAddInvoiceProcWithMetaDataUsingArrayParams() throws Exception {
initializeAddInvoiceWithMetaData(false);
SimpleJdbcCall adder = new SimpleJdbcCall(dataSource).withProcedureName("add_invoice");
Number newId = adder.executeObject(Number.class, 1103, 3);
assertEquals(4, newId.intValue());
verifyAddInvoiceWithMetaData(false);
verify(connection, atLeastOnce()).close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testAddInvoiceFuncWithMetaDataUsingArrayParams() throws Exception {
initializeAddInvoiceWithMetaData(true);
SimpleJdbcCall adder = new SimpleJdbcCall(dataSource).withFunctionName("add_invoice");
Number newId = adder.executeFunction(Number.class, 1103, 3);
assertEquals(4, newId.intValue());
verifyAddInvoiceWithMetaData(true);
verify(connection, atLeastOnce()).close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testAddInvoiceFuncWithMetaDataUsingMapParamSource() throws Exception {
initializeAddInvoiceWithMetaData(true);
SimpleJdbcCall adder = new SimpleJdbcCall(dataSource).withFunctionName("add_invoice");
Number newId = adder.executeFunction(Number.class, new MapSqlParameterSource()
.addValue("amount", 1103)
.addValue("custid", 3));
assertEquals(4, newId.intValue());
verifyAddInvoiceWithMetaData(true);
verify(connection, atLeastOnce()).close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testAddInvoiceProcWithMetaDataUsingMapParamSource() throws Exception {
initializeAddInvoiceWithMetaData(false);
SimpleJdbcCall adder = new SimpleJdbcCall(dataSource).withProcedureName("add_invoice");
Number newId = adder.executeObject(Number.class, new MapSqlParameterSource()
.addValue("amount", 1103)
.addValue("custid", 3));
assertEquals(4, newId.intValue());
verifyAddInvoiceWithMetaData(false);
verify(connection, atLeastOnce()).close();
}
内容来源于网络,如有侵权,请联系作者删除!