@Override public Object putIfAbsent(Object key, Object value) { return (hashOps.putIfAbsent((String) key, (String) value) ? null : get(key)); }
/** * Retrieve the persisted value for the provided key. * * @param key Must not be null */ @Override public String get(String key) { Assert.notNull(key, "'key' must not be null."); Object value = this.properties.get(key); if (value != null) { Assert.isInstanceOf(String.class, value, "Invalid type in the store"); } return (String) value; }
@Test @RedisAvailable public void testProperties() { RedisProperties redisProperties = new RedisProperties("pepboys", this.redisTemplate); assertEquals(0, redisProperties.size()); Properties pepboys = new Properties(); pepboys.put("1", "Manny"); pepboys.put("2", "Moe"); pepboys.put("3", "Jack"); Message<Properties> message = MessageBuilder.withPayload(pepboys).build(); this.propertyChannel.send(message); assertEquals("Manny", redisProperties.get("1")); assertEquals("Moe", redisProperties.get("2")); assertEquals("Jack", redisProperties.get("3")); }
@Test @RedisAvailable public void testPropertiesSimple() { RedisProperties redisProperties = new RedisProperties("foo", this.redisTemplate); assertEquals(0, redisProperties.size()); Message<String> message = MessageBuilder.withPayload("bar") .setHeader(RedisHeaders.KEY, "foo") .setHeader("baz", "qux") .build(); this.simplePropertyChannel.send(message); assertEquals("bar", redisProperties.get("qux")); }
/** * Retrieve the persisted value for the provided key. * * @param key Must not be null */ @Override public String get(String key) { Assert.notNull(key, "'key' must not be null."); Object value = this.properties.get(key); if (value != null) { Assert.isInstanceOf(String.class, value, "Invalid type in the store"); } return (String) value; }
@Override public Object putIfAbsent(Object key, Object value) { return (hashOps.putIfAbsent((String) key, (String) value) ? null : get(key)); }
@Override public Object putIfAbsent(Object key, Object value) { return (hashOps.putIfAbsent((String) key, (String) value) ? null : get(key)); }