@Override public Object decode(Object jv) { if (jv instanceof Number) { return Integer.valueOf(((Number) jv).intValue()); } return (Integer) null; } };
@Override public Object decode(Object jv) throws IOException { if (jv instanceof Number) { return new AtomicInteger(((Number) jv).intValue()); } return (AtomicInteger) null; } };
@Override public Integer apply(Number x) { return x.intValue(); } };
/** * 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(); }
/** * 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(); }
/** * 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()); }
/** * 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()); }
/** * 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()); }
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(); } }
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(); } }
public int execute(int amount, int custid) { Map<String, Object> out = execute(new Object[] { amount, custid }); return ((Number) out.get("newid")).intValue(); } }
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()); }
@Test public void singleKey() { kh.getKeyList().addAll(singletonList(singletonMap("key", 1))); assertEquals("single key should be returned", 1, kh.getKey().intValue()); }
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()); }
@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(); }
@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()); }
@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(); }
@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(); }
@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(); }
@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(); }