From 078068d8ffb9d865f63ac1070fc452879c445d1c Mon Sep 17 00:00:00 2001 From: leventov Date: Mon, 18 May 2015 13:51:03 +0100 Subject: [PATCH] Extract MapAbsentEntryOperations.shouldInsert() for subclassing ease --- .../chronicle/map/MapAbsentEntryOperations.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/map/MapAbsentEntryOperations.java b/src/main/java/net/openhft/chronicle/map/MapAbsentEntryOperations.java index 0585c87e9..10041ef06 100644 --- a/src/main/java/net/openhft/chronicle/map/MapAbsentEntryOperations.java +++ b/src/main/java/net/openhft/chronicle/map/MapAbsentEntryOperations.java @@ -32,6 +32,14 @@ import static net.openhft.chronicle.hash.replication.DefaultEventualConsistencyS * @param type of the value in {@code ChronicleMap} */ public interface MapAbsentEntryOperations { + + static boolean shoudInsert(@NotNull MapAbsentEntry absentEntry) { + MapContext context = absentEntry.context(); + return !(context instanceof ReplicationContext) || + !(absentEntry instanceof ReplicatedEntry) || + shouldApplyRemoteModification((ReplicatedEntry) absentEntry, + (ReplicationContext) context); + } /** * Inserts the new entry into the map, of {@link MapAbsentEntry#absentKey() the key} from @@ -43,12 +51,7 @@ public interface MapAbsentEntryOperations { * operation are not met */ default boolean insert(@NotNull MapAbsentEntry absentEntry, Value value) { - MapContext context = absentEntry.context(); - boolean shouldInsert = !(context instanceof ReplicationContext) || - !(absentEntry instanceof ReplicatedEntry) || - shouldApplyRemoteModification((ReplicatedEntry) absentEntry, - (ReplicationContext) context); - if (shouldInsert) { + if (shoudInsert(absentEntry)) { absentEntry.doInsert(value); return true; } else {