@Override public Object decode(Object jv) { if (jv instanceof Number) { return ((Number) jv).doubleValue(); } return (double) 0; } };
@Override public Object decode(Object jv) { if (jv instanceof Number) { return ((Number) jv).longValue(); } return (long) 0; } };
@Override public Object decode(Object jv) { if (jv instanceof Number) { return ((Number) jv).floatValue(); } return (float) 0; } };
@Override public Integer apply(Number x) { return x.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()); }
@Override public Object decode(Object jv) { if (jv instanceof Number) { return ((Number) jv).shortValue(); } return (short) 0; } };
@Override public Object decode(Object jv) { if (jv instanceof Number) { return ((Number) jv).byteValue(); } return (byte) 0; } };
/** * 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(); }
@Override public Object decode(Object jv) { if (jv instanceof Number) { return ((Number) jv).shortValue(); } return (short) 0; } };
@Override public Object decode(Object jv) { if (jv instanceof Number) { return ((Number) jv).byteValue(); } return (byte) 0; } };
@Override public Object decode(Object jv) { if (jv instanceof Number) { return ((Number) jv).doubleValue(); } return (double) 0; } };
/** * 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(); }
@Override public Object decode(Object jv) { if (jv instanceof Number) { return ((Number) jv).longValue(); } return (long) 0; } };
@Override public Object decode(Object jv) { if (jv instanceof Number) { return ((Number) jv).floatValue(); } return (float) 0; } };
@Override public Character convert(Number source) { return (char) source.shortValue(); }
/** * Subtracts a value from the value of this instance. * * @param operand the value to subtract, not null * @throws NullPointerException if the object is null * @since 2.2 */ public void subtract(final Number operand) { this.value -= operand.byteValue(); }
@Override public Object decode(Object jv) throws IOException { if (jv instanceof Number) { return BigDecimal.valueOf(((Number) jv).doubleValue()); } return (BigDecimal) null; } };
/** * 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()); }
/** * get long value. * * @param key key. * @param def default value. * @return value or default value. */ public long getLong(String key, long def) { Object tmp = mMap.get(key); return tmp != null && tmp instanceof Number ? ((Number) tmp).longValue() : def; }
/** * get float value. * * @param index index. * @param def default value. * @return value or default value. */ public float getFloat(int index, float def) { Object tmp = mArray.get(index); return tmp != null && tmp instanceof Number ? ((Number) tmp).floatValue() : def; }