parent
c972ec4383
commit
e0efdcae22
4 changed files with 19 additions and 6 deletions
|
@ -169,6 +169,7 @@ public class GenerateHotRodEntityImplementationsProcessor extends AbstractGenera
|
|||
pw.println(" " +
|
||||
"public " + hotRodSimpleClassName + "(" + className + " " + ENTITY_VARIABLE + ") {"
|
||||
);
|
||||
pw.println(" java.util.Objects.requireNonNull(" + ENTITY_VARIABLE + ");");
|
||||
pw.println(" this." + ENTITY_VARIABLE + " = " + ENTITY_VARIABLE + ";");
|
||||
if (usingGeneratedCloner) {
|
||||
pw.println(" this.cloner = DeepCloner.DUMB_CLONER;");
|
||||
|
|
|
@ -93,15 +93,25 @@ public class HotRodMapStorage<K, E extends AbstractHotRodEntity, V extends HotRo
|
|||
Objects.requireNonNull(key, "Key must be non-null");
|
||||
K k = keyConverter.fromStringSafe(key);
|
||||
|
||||
V v = delegateProducer.apply(remoteCache.get(k));
|
||||
if (v == null || v.getHotRodEntity() == null) return null;
|
||||
return isExpirableEntity && isExpired((ExpirableEntity) v, true) ? null : v;
|
||||
// Obtain value from Infinispan
|
||||
E hotRodEntity = remoteCache.get(k);
|
||||
if (hotRodEntity == null) return null;
|
||||
|
||||
// Create delegate that implements Map*Entity
|
||||
V delegateEntity = delegateProducer.apply(hotRodEntity);
|
||||
|
||||
// Check expiration if necessary and return value
|
||||
return isExpirableEntity && isExpired((ExpirableEntity) delegateEntity, true) ? null : delegateEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V update(V value) {
|
||||
K key = keyConverter.fromStringSafe(value.getId());
|
||||
return delegateProducer.apply(remoteCache.replace(key, value.getHotRodEntity()));
|
||||
|
||||
E previousValue = remoteCache.replace(key, value.getHotRodEntity());
|
||||
if (previousValue == null) return null;
|
||||
|
||||
return delegateProducer.apply(previousValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -95,8 +95,7 @@ public class SingleUseObjectHotRodMapStorage<K, E extends AbstractHotRodEntity,
|
|||
SingleUseObjectModelCriteriaBuilder mcb = criteria.flashToModelCriteriaBuilder(createSingleUseObjectCriteriaBuilder());
|
||||
if (mcb.isValid()) {
|
||||
HotRodSingleUseObjectEntityDelegate value = read(mcb.getKey());
|
||||
|
||||
return value != null && value.getHotRodEntity() != null ? Stream.of(value) : Stream.empty();
|
||||
return value != null ? Stream.of(value) : Stream.empty();
|
||||
}
|
||||
|
||||
return super.read(queryParameters);
|
||||
|
|
|
@ -37,6 +37,9 @@ public interface ConcurrentHashMapCrudOperations<V extends AbstractEntity & Upda
|
|||
* Updates the object with the key of the {@code value}'s ID in the storage if it already exists.
|
||||
*
|
||||
* @param value Updated value
|
||||
* @return the previous value associated with the specified key, or null if there was no mapping for the key.
|
||||
* (A null return can also indicate that the map previously associated null with the key,
|
||||
* if the implementation supports null values.)
|
||||
* @throws NullPointerException if the object or its {@code id} is {@code null}
|
||||
* @see AbstractEntity#getId()
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue