@@ -285,7 +285,7 @@ private V put(@Nullable final K key, @Nullable final V value, final boolean over
285
285
return doTask (key , new Task <V >(TaskOption .RESTRUCTURE_BEFORE , TaskOption .RESIZE ) {
286
286
@ Override
287
287
@ Nullable
288
- protected V execute (@ Nullable Reference <K , V > ref , @ Nullable Entry <K , V > entry , @ Nullable Entries entries ) {
288
+ protected V execute (@ Nullable Reference <K , V > ref , @ Nullable Entry <K , V > entry , @ Nullable Entries < V > entries ) {
289
289
if (entry != null ) {
290
290
V oldValue = entry .getValue ();
291
291
if (overwriteExisting ) {
@@ -530,15 +530,12 @@ public <T> T doTask(final int hash, @Nullable final Object key, final Task<T> ta
530
530
final Reference <K , V > head = this .references [index ];
531
531
Reference <K , V > ref = findInChain (head , key , hash );
532
532
Entry <K , V > entry = (ref != null ? ref .get () : null );
533
- Entries entries = new Entries () {
534
- @ Override
535
- public void add (@ Nullable V value ) {
536
- @ SuppressWarnings ("unchecked" )
537
- Entry <K , V > newEntry = new Entry <>((K ) key , value );
538
- Reference <K , V > newReference = Segment .this .referenceManager .createReference (newEntry , hash , head );
539
- Segment .this .references [index ] = newReference ;
540
- Segment .this .count .incrementAndGet ();
541
- }
533
+ Entries <V > entries = value -> {
534
+ @ SuppressWarnings ("unchecked" )
535
+ Entry <K , V > newEntry = new Entry <>((K ) key , value );
536
+ Reference <K , V > newReference = Segment .this .referenceManager .createReference (newEntry , hash , head );
537
+ Segment .this .references [index ] = newReference ;
538
+ Segment .this .count .incrementAndGet ();
542
539
};
543
540
return task .execute (ref , entry , entries );
544
541
}
@@ -802,7 +799,7 @@ public boolean hasOption(TaskOption option) {
802
799
* @see #execute(Reference, Entry)
803
800
*/
804
801
@ Nullable
805
- protected T execute (@ Nullable Reference <K , V > ref , @ Nullable Entry <K , V > entry , @ Nullable Entries entries ) {
802
+ protected T execute (@ Nullable Reference <K , V > ref , @ Nullable Entry <K , V > entry , @ Nullable Entries < V > entries ) {
806
803
return execute (ref , entry );
807
804
}
808
805
@@ -830,15 +827,15 @@ private enum TaskOption {
830
827
831
828
832
829
/**
833
- * Allows a task access to {@link Segment} entries.
830
+ * Allows a task access to {@link ConcurrentReferenceHashMap. Segment} entries.
834
831
*/
835
- private abstract class Entries {
832
+ private interface Entries < V > {
836
833
837
834
/**
838
835
* Add a new entry with the specified value.
839
836
* @param value the value to add
840
837
*/
841
- public abstract void add (@ Nullable V value );
838
+ void add (@ Nullable V value );
842
839
}
843
840
844
841
0 commit comments