List of usage examples for org.springframework.data.redis.serializer SerializationUtils isEmpty
static boolean isEmpty(@Nullable byte[] data)
From source file:org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer.java
@SuppressWarnings("unchecked") public T deserialize(byte[] bytes) throws SerializationException { if (SerializationUtils.isEmpty(bytes)) { return null; }/*w w w.ja va2 s . c om*/ try { return (T) this.objectMapper.readValue(bytes, 0, bytes.length, javaType); } catch (Exception ex) { throw new SerializationException("Could not read JSON: " + ex.getMessage(), ex); } }
From source file:org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer.java
/** * @param source/*ww w. ja v a 2s . c o m*/ * can be {@literal null}. * @param type * must not be {@literal null}. * @return {@literal null} for empty source. * @throws SerializationException */ public <T> T deserialize(byte[] source, Class<T> type) throws SerializationException { Assert.notNull(type, "Deserialization type must not be null! Pleaes provide Object.class to make use of Jackson2 default typing."); if (SerializationUtils.isEmpty(source)) { return null; } try { return mapper.readValue(source, type); } catch (final Exception ex) { throw new SerializationException("Could not read JSON: " + ex.getMessage(), ex); } }