org.springframework.cache.support.NullValue Java Examples

The following examples show how to use org.springframework.cache.support.NullValue. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JacksonConfig.java    From syhthems-platform with MIT License 5 votes vote down vote up
@Override
public void serialize(NullValue value, JsonGenerator jgen, SerializerProvider provider)
        throws IOException {

    jgen.writeStartObject();
    jgen.writeStringField(classIdentifier, NullValue.class.getName());
    jgen.writeEndObject();
}
 
Example #2
Source File: J2CacheCache.java    From spring-boot-tutorial with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
@Override
protected Object lookup(Object key) {
    CacheObject cacheObject = cacheChannel.get(j2CacheName, String.valueOf(key));
    if (cacheObject.rawValue() != null && cacheObject.rawValue().getClass().equals(NullObject.class)
        && super.isAllowNullValues()) {
        return NullValue.INSTANCE;
    }
    return cacheObject.getValue();
}
 
Example #3
Source File: J2CacheCache.java    From J2Cache with Apache License 2.0 5 votes vote down vote up
@Override
protected Object lookup(Object key) {
	CacheObject cacheObject = cacheChannel.get(j2CacheName, String.valueOf(key), false);
	if(cacheObject.rawValue() != null && cacheObject.rawValue().getClass().equals(NullObject.class) && super.isAllowNullValues()) {
		return NullValue.INSTANCE;
	}
	return cacheObject.getValue();
}
 
Example #4
Source File: J2CacheSpringCacheAdapter.java    From J2Cache with Apache License 2.0 5 votes vote down vote up
@Override
protected Object lookup(Object key) {
    Object value = j2Cache.get(name, getKey(key), false).rawValue();
    if (value == null || value.getClass().equals(Object.class)) {
        return null;
    }
    if (value.getClass().equals(NullObject.class)) {
        return NullValue.INSTANCE;
    }
    return value;
}
 
Example #5
Source File: J2CacheCache.java    From J2Cache with Apache License 2.0 5 votes vote down vote up
@Override
protected Object lookup(Object key) {
	CacheObject cacheObject = cacheChannel.get(j2CacheName, String.valueOf(key), false);
	if(cacheObject.rawValue() != null && cacheObject.rawValue().getClass().equals(NullObject.class) && super.isAllowNullValues()) {
		return NullValue.INSTANCE;
	}
	return cacheObject.getValue();
}
 
Example #6
Source File: MemcachedCacheTest.java    From memcached-spring-boot with Apache License 2.0 5 votes vote down vote up
@Test
public void whenPutNullThenStoreNullValueInstance() {
    when(memcachedClient.get(namespaceKey)).thenReturn(NAMESPACE_KEY_VALUE);

    memcachedCache.put(CACHED_OBJECT_KEY, null);

    verify(memcachedClient).get(namespaceKey);
    verify(memcachedClient).set(memcachedKey, CACHE_EXPIRATION, NullValue.INSTANCE);
    verify(memcachedClient).touch(namespaceKey, CACHE_EXPIRATION);
}
 
Example #7
Source File: JacksonConfig.java    From syhthems-platform with MIT License 4 votes vote down vote up
/**
 * @param classIdentifier can be {@literal null} and will be defaulted to {@code @class}.
 */
CustomNullValueSerializer(@Nullable String classIdentifier) {

    super(NullValue.class);
    this.classIdentifier = StringUtils.hasText(classIdentifier) ? classIdentifier : "@class";
}
 
Example #8
Source File: GenericMsgpackRedisSerializer.java    From Ffast-Java with MIT License 4 votes vote down vote up
NullValueSerializer(@Nullable String classIdentifier) {
    super(NullValue.class);
    this.classIdentifier = StringUtils.hasText(classIdentifier) ? classIdentifier : "@class";
}
 
Example #9
Source File: GenericMsgpackRedisSerializer.java    From Ffast-Java with MIT License 4 votes vote down vote up
@Override
public void serialize(NullValue value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
    jgen.writeStartObject();
    jgen.writeStringField(this.classIdentifier, NullValue.class.getName());
    jgen.writeEndObject();
}