    @Override
    public Iterator<Document> iterator()
    {
        return new PrefetchingIterator<>()
        {
            DocIdSetIterator idIterator = iterateAllDocs();

            @Override
            protected Document fetchNextOrNull()
            {
                try
                {
                    int doc = idIterator.nextDoc();
                    if ( doc == DocIdSetIterator.NO_MORE_DOCS )
                    {
                        return null;
                    }
                    return getDocument( doc );
                }
                catch ( IOException e )
                {
                    throw new LuceneDocumentRetrievalException( "Can't fetch document id from lucene index.", e );
                }
            }
        };
    }

    @Override
    public Iterator<Document> iterator()
    {
        return new PrefetchingIterator<Document>()
        {
            DocIdSetIterator idIterator = iterateAllDocs();

            @Override
            protected Document fetchNextOrNull()
            {
                try
                {
                    int doc = idIterator.nextDoc();
                    if ( doc == DocIdSetIterator.NO_MORE_DOCS )
                    {
                        return null;
                    }
                    return getDocument( doc );
                }
                catch ( IOException e )
                {
                    throw new LuceneDocumentRetrievalException( "Can't fetch document id from lucene index.", e );
                }
            }
        };
    }

Replace Generic With Diamond PrefetchingIterator<Document> with PrefetchingIterator<> in method public iterator() : Iterator<Document> from class org.neo4j.kernel.api.impl.index.LucenePartitionAllDocumentsReader


    @Override
    public Iterator<Long> iterator()
    {
        Iterator<Document> iterator = documents.iterator();
        return new Iterator<>()
        {
            @Override
            public boolean hasNext()
            {
                return iterator.hasNext();
            }

            @Override
            public Long next()
            {
                return entityIdReader.applyAsLong( iterator.next() );
            }
        };
    }

    @Override
    public Iterator<Long> iterator()
    {
        Iterator<Document> iterator = documents.iterator();
        return new Iterator<Long>()
        {
            @Override
            public boolean hasNext()
            {
                return iterator.hasNext();
            }

            @Override
            public Long next()
            {
                return entityIdReader.applyAsLong( iterator.next() );
            }
        };
    }

Replace Generic With Diamond Iterator<Long> with Iterator<> in method public iterator() : Iterator<Long> from class org.neo4j.kernel.api.impl.schema.reader.LuceneAllEntriesIndexAccessorReader


    /**
     * @return cached {@link RelationshipGroupRecord} sorted by node id and then type id.
     */
    @Override
    public Iterator<RelationshipGroupRecord> iterator()
    {
        return new PrefetchingIterator<>()
        {
            private long cursor;
            private long nodeId = fromNodeId;
            private int countLeftForThisNode = groupCount( nodeId );

            {
                findNextNodeWithGroupsIfNeeded();
            }

            @Override
            protected RelationshipGroupRecord fetchNextOrNull()
            {
                while ( cursor < highCacheId )
                {
                    RelationshipGroupRecord group = null;
                    if ( cache.getByte( cursor, 0 ) == 1 )
                    {
                        // Here we have an alive group
                        group = new RelationshipGroupRecord( -1 ).initialize( true,
                                                                              cache.get3ByteInt( cursor, 1 ),
                                                                              cache.get6ByteLong( cursor, 1 + 3 ),
                                                                              cache.get6ByteLong( cursor, 1 + 3 + 6 ),
                                                                              cache.get6ByteLong( cursor, 1 + 3 + 6 + 6 ),
                                                                              nodeId,
                                                                              // Special: we want to convey information about how many groups are coming
                                                                              // after this one so that chains can be ordered accordingly in the store
                                                                              // so this isn't at all "next" in the true sense of chain next.
                                                                              countLeftForThisNode - 1 );
                    }

                    cursor++;
                    countLeftForThisNode--;
                    findNextNodeWithGroupsIfNeeded();

                    if ( group != null )
                    {
                        return group;
                    }
                }
                return null;
            }

            private void findNextNodeWithGroupsIfNeeded()
            {
                if ( countLeftForThisNode == 0 )
                {
                    do
                    {
                        nodeId++;
                        countLeftForThisNode = nodeId >= groupCountCache.length() ? 0 : groupCount( nodeId );
                    }
                    while ( countLeftForThisNode == 0 && nodeId < groupCountCache.length() );
                }
            }
        };
    }

    /**
     * @return cached {@link RelationshipGroupRecord} sorted by node id and then type id.
     */
    @Override
    public Iterator<RelationshipGroupRecord> iterator()
    {
        return new PrefetchingIterator<RelationshipGroupRecord>()
        {
            private long cursor;
            private long nodeId = fromNodeId;
            private int countLeftForThisNode = groupCount( nodeId );
            {
                findNextNodeWithGroupsIfNeeded();
            }

            @Override
            protected RelationshipGroupRecord fetchNextOrNull()
            {
                while ( cursor < highCacheId )
                {
                    RelationshipGroupRecord group = null;
                    if ( cache.getByte( cursor, 0 ) == 1 )
                    {
                        // Here we have an alive group
                        group = new RelationshipGroupRecord( -1 ).initialize( true,
                                cache.get3ByteInt( cursor, 1 ),
                                cache.get6ByteLong( cursor, 1 + 3 ),
                                cache.get6ByteLong( cursor, 1 + 3 + 6 ),
                                cache.get6ByteLong( cursor, 1 + 3 + 6 + 6 ),
                                nodeId,
                                // Special: we want to convey information about how many groups are coming
                                // after this one so that chains can be ordered accordingly in the store
                                // so this isn't at all "next" in the true sense of chain next.
                                countLeftForThisNode - 1 );
                    }

                    cursor++;
                    countLeftForThisNode--;
                    findNextNodeWithGroupsIfNeeded();

                    if ( group != null )
                    {
                        return group;
                    }
                }
                return null;
            }

            private void findNextNodeWithGroupsIfNeeded()
            {
                if ( countLeftForThisNode == 0 )
                {
                    do
                    {
                        nodeId++;
                        countLeftForThisNode = nodeId >= groupCountCache.length() ? 0 : groupCount( nodeId );
                    }
                    while ( countLeftForThisNode == 0 && nodeId < groupCountCache.length() );
                }
            }
        };
    }

Replace Generic With Diamond PrefetchingIterator<RelationshipGroupRecord> with PrefetchingIterator<> in method public iterator() : Iterator<RelationshipGroupRecord> from class org.neo4j.internal.batchimport.RelationshipGroupCache


    /**
     * @param stat statistics {@link Key}.
     * @param trueForAscending {@code true} for ordering by ascending, otherwise descending.
     * @return the steps ordered by the {@link Stat#asLong() long value representation} of the given
     * {@code stat} accompanied a factor by how it compares to the next value, where a value close to
     * {@code 1.0} signals them being close to equal, and a value of for example {@code 0.5} signals that
     * the value of the current step is half that of the next step.
     */
    public Iterable<Pair<Step<?>,Float>> stepsOrderedBy( final Key stat, final boolean trueForAscending )
    {
        final List<Step<?>> steps = new ArrayList<>( pipeline );
        steps.sort( ( o1, o2 ) -> {
            Long stat1 = o1.stats().stat( stat ).asLong();
            Long stat2 = o2.stats().stat( stat ).asLong();
            return trueForAscending ? stat1.compareTo( stat2 ) : stat2.compareTo( stat1 );
        } );

        return () -> new PrefetchingIterator<>()
        {
            private final Iterator<Step<?>> source = steps.iterator();
            private Step<?> next = source.hasNext() ? source.next() : null;

            @Override
            protected Pair<Step<?>,Float> fetchNextOrNull()
            {
                if ( next == null )
                {
                    return null;
                }

                Step<?> current = next;
                next = source.hasNext() ? source.next() : null;
                float factor = next != null
                               ? (float) stat( current, stat ) / (float) stat( next, stat )
                               : 1.0f;
                return Pair.of( current, factor );
            }

            private long stat( Step<?> step, Key stat12 )
            {
                return step.stats().stat( stat12 ).asLong();
            }
        };
    }

    /**
     * @param stat statistics {@link Key}.
     * @param trueForAscending {@code true} for ordering by ascending, otherwise descending.
     * @return the steps ordered by the {@link Stat#asLong() long value representation} of the given
     * {@code stat} accompanied a factor by how it compares to the next value, where a value close to
     * {@code 1.0} signals them being close to equal, and a value of for example {@code 0.5} signals that
     * the value of the current step is half that of the next step.
     */
    public Iterable<Pair<Step<?>,Float>> stepsOrderedBy( final Key stat, final boolean trueForAscending )
    {
        final List<Step<?>> steps = new ArrayList<>( pipeline );
        steps.sort( ( o1, o2 ) -> {
            Long stat1 = o1.stats().stat( stat ).asLong();
            Long stat2 = o2.stats().stat( stat ).asLong();
            return trueForAscending ? stat1.compareTo( stat2 ) : stat2.compareTo( stat1 );
        } );

        return () -> new PrefetchingIterator<Pair<Step<?>,Float>>()
        {
            private final Iterator<Step<?>> source = steps.iterator();
            private Step<?> next = source.hasNext() ? source.next() : null;

            @Override
            protected Pair<Step<?>,Float> fetchNextOrNull()
            {
                if ( next == null )
                {
                    return null;
                }

                Step<?> current = next;
                next = source.hasNext() ? source.next() : null;
                float factor = next != null
                        ? (float) stat( current, stat ) / (float) stat( next, stat )
                        : 1.0f;
                return Pair.of( current, factor );
            }

            private long stat( Step<?> step, Key stat12 )
            {
                return step.stats().stat( stat12 ).asLong();
            }
        };
    }

Replace Generic With Diamond PrefetchingIterator<Pair<Step<?>,Float>> with PrefetchingIterator<> in method public stepsOrderedBy(stat Key, trueForAscending boolean) : Iterable<Pair<Step<?>,Float>> from class org.neo4j.internal.batchimport.staging.StageExecution


    @Override
    public Iterable<RecordProxy<RECORD,ADDITIONAL>> changes()
    {
        return new IterableWrapper<>(
                batch.values() )
        {
            @Override
            protected RecordProxy<RECORD,ADDITIONAL> underlyingObjectToObject( DirectRecordProxy object )
            {
                return object;
            }
        };
    }

    @Override
    public Iterable<RecordProxy<RECORD,ADDITIONAL>> changes()
    {
        return new IterableWrapper<RecordProxy<RECORD,ADDITIONAL>,DirectRecordProxy>(
                batch.values() )
        {
            @Override
            protected RecordProxy<RECORD,ADDITIONAL> underlyingObjectToObject( DirectRecordProxy object )
            {
                return object;
            }
        };
    }

Replace Generic With Diamond IterableWrapper<RecordProxy<RECORD,ADDITIONAL>,DirectRecordProxy> with IterableWrapper<> in method public changes() : Iterable<RecordProxy<RECORD,ADDITIONAL>> from class org.neo4j.internal.recordstorage.DirectRecordAccess


    private Iterable<IndexEntryUpdate<SchemaDescriptor>> combinedUpdates()
    {
        return () -> new NestingIterator<>( updates.iterator() )
        {
            @Override
            protected Iterator<IndexEntryUpdate<SchemaDescriptor>> createNestedIterator( IndexUpdates item )
            {
                return item.iterator();
            }
        };
    }

    private Iterable<IndexEntryUpdate<SchemaDescriptor>> combinedUpdates()
    {
        return () -> new NestingIterator<IndexEntryUpdate<SchemaDescriptor>,IndexUpdates>( updates.iterator() )
        {
            @Override
            protected Iterator<IndexEntryUpdate<SchemaDescriptor>> createNestedIterator( IndexUpdates item )
            {
                return item.iterator();
            }
        };
    }

Replace Generic With Diamond NestingIterator<IndexEntryUpdate<SchemaDescriptor>,IndexUpdates> with NestingIterator<> in method private combinedUpdates() : Iterable<IndexEntryUpdate<SchemaDescriptor>> from class org.neo4j.internal.recordstorage.IndexUpdatesWork


    public static Loader<NodeRecord,Void> nodeLoader( final RecordStore<NodeRecord> store )
    {
        return new Loader<>()
        {
            @Override
            public NodeRecord newUnused( long key, Void additionalData )
            {
                return andMarkAsCreated( new NodeRecord( key ) );
            }

            @Override
            public NodeRecord load( long key, Void additionalData )
            {
                return store.getRecord( key, store.newRecord(), NORMAL );
            }

            @Override
            public void ensureHeavy( NodeRecord record )
            {
                store.ensureHeavy( record );
            }

            @Override
            public NodeRecord clone( NodeRecord nodeRecord ) throws CloneNotSupportedException
            {
                return nodeRecord.clone();
            }
        };
    }

    public static Loader<NodeRecord,Void> nodeLoader( final RecordStore<NodeRecord> store )
    {
        return new Loader<NodeRecord,Void>()
        {
            @Override
            public NodeRecord newUnused( long key, Void additionalData )
            {
                return andMarkAsCreated( new NodeRecord( key ) );
            }

            @Override
            public NodeRecord load( long key, Void additionalData )
            {
                return store.getRecord( key, store.newRecord(), NORMAL );
            }

            @Override
            public void ensureHeavy( NodeRecord record )
            {
                store.ensureHeavy( record );
            }

            @Override
            public NodeRecord clone( NodeRecord nodeRecord ) throws CloneNotSupportedException
            {
                return nodeRecord.clone();
            }
        };
    }

Replace Generic With Diamond Loader<NodeRecord,Void> with Loader<> in method public nodeLoader(store RecordStore<NodeRecord>) : Loader<NodeRecord,Void> from class org.neo4j.internal.recordstorage.Loaders


    public static Loader<PropertyRecord,PrimitiveRecord> propertyLoader( final PropertyStore store )
    {
        return new Loader<>()
        {
            @Override
            public PropertyRecord newUnused( long key, PrimitiveRecord additionalData )
            {
                PropertyRecord record = new PropertyRecord( key );
                setOwner( record, additionalData );
                return andMarkAsCreated( record );
            }

            private void setOwner( PropertyRecord record, PrimitiveRecord owner )
            {
                if ( owner != null )
                {
                    owner.setIdTo( record );
                }
            }

            @Override
            public PropertyRecord load( long key, PrimitiveRecord additionalData )
            {
                PropertyRecord record = store.getRecord( key, store.newRecord(), NORMAL );
                setOwner( record, additionalData );
                return record;
            }

            @Override
            public void ensureHeavy( PropertyRecord record )
            {
                for ( PropertyBlock block : record )
                {
                    store.ensureHeavy( block );
                }
            }

            @Override
            public PropertyRecord clone( PropertyRecord propertyRecord ) throws CloneNotSupportedException
            {
                return propertyRecord.clone();
            }
        };
    }

    public static Loader<PropertyRecord,PrimitiveRecord> propertyLoader( final PropertyStore store )
    {
        return new Loader<PropertyRecord,PrimitiveRecord>()
        {
            @Override
            public PropertyRecord newUnused( long key, PrimitiveRecord additionalData )
            {
                PropertyRecord record = new PropertyRecord( key );
                setOwner( record, additionalData );
                return andMarkAsCreated( record );
            }

            private void setOwner( PropertyRecord record, PrimitiveRecord owner )
            {
                if ( owner != null )
                {
                    owner.setIdTo( record );
                }
            }

            @Override
            public PropertyRecord load( long key, PrimitiveRecord additionalData )
            {
                PropertyRecord record = store.getRecord( key, store.newRecord(), NORMAL );
                setOwner( record, additionalData );
                return record;
            }

            @Override
            public void ensureHeavy( PropertyRecord record )
            {
                for ( PropertyBlock block : record )
                {
                    store.ensureHeavy( block );
                }
            }

            @Override
            public PropertyRecord clone( PropertyRecord propertyRecord ) throws CloneNotSupportedException
            {
                return propertyRecord.clone();
            }
        };
    }

Replace Generic With Diamond Loader<PropertyRecord,PrimitiveRecord> with Loader<> in method public propertyLoader(store PropertyStore) : Loader<PropertyRecord,PrimitiveRecord> from class org.neo4j.internal.recordstorage.Loaders


    public static Loader<RelationshipRecord,Void> relationshipLoader(
            final RecordStore<RelationshipRecord> store )
    {
        return new Loader<>()
        {
            @Override
            public RelationshipRecord newUnused( long key, Void additionalData )
            {
                return andMarkAsCreated( new RelationshipRecord( key ) );
            }

            @Override
            public RelationshipRecord load( long key, Void additionalData )
            {
                return store.getRecord( key, store.newRecord(), NORMAL );
            }

            @Override
            public void ensureHeavy( RelationshipRecord record )
            {   // Nothing to load
            }

            @Override
            public RelationshipRecord clone( RelationshipRecord relationshipRecord ) throws CloneNotSupportedException
            {
                return relationshipRecord.clone();
            }
        };
    }

    public static Loader<RelationshipRecord,Void> relationshipLoader(
            final RecordStore<RelationshipRecord> store )
    {
        return new Loader<RelationshipRecord, Void>()
        {
            @Override
            public RelationshipRecord newUnused( long key, Void additionalData )
            {
                return andMarkAsCreated( new RelationshipRecord( key ) );
            }

            @Override
            public RelationshipRecord load( long key, Void additionalData )
            {
                return store.getRecord( key, store.newRecord(), NORMAL );
            }

            @Override
            public void ensureHeavy( RelationshipRecord record )
            {   // Nothing to load
            }

            @Override
            public RelationshipRecord clone( RelationshipRecord relationshipRecord ) throws CloneNotSupportedException
            {
                return relationshipRecord.clone();
            }
        };
    }

Replace Generic With Diamond Loader<RelationshipRecord,Void> with Loader<> in method public relationshipLoader(store RecordStore<RelationshipRecord>) : Loader<RelationshipRecord,Void> from class org.neo4j.internal.recordstorage.Loaders


    public static Loader<RelationshipGroupRecord,Integer> relationshipGroupLoader(
            final RecordStore<RelationshipGroupRecord> store )
    {
        return new Loader<>()
        {
            @Override
            public RelationshipGroupRecord newUnused( long key, Integer type )
            {
                RelationshipGroupRecord record = new RelationshipGroupRecord( key );
                record.setType( type );
                return andMarkAsCreated( record );
            }

            @Override
            public RelationshipGroupRecord load( long key, Integer type )
            {
                return store.getRecord( key, store.newRecord(), NORMAL );
            }

            @Override
            public void ensureHeavy( RelationshipGroupRecord record )
            {   // Not needed
            }

            @Override
            public RelationshipGroupRecord clone( RelationshipGroupRecord record ) throws CloneNotSupportedException
            {
                return record.clone();
            }
        };
    }

    public static Loader<RelationshipGroupRecord,Integer> relationshipGroupLoader(
            final RecordStore<RelationshipGroupRecord> store )
    {
        return new Loader<RelationshipGroupRecord, Integer>()
        {
            @Override
            public RelationshipGroupRecord newUnused( long key, Integer type )
            {
                RelationshipGroupRecord record = new RelationshipGroupRecord( key );
                record.setType( type );
                return andMarkAsCreated( record );
            }

            @Override
            public RelationshipGroupRecord load( long key, Integer type )
            {
                return store.getRecord( key, store.newRecord(), NORMAL );
            }

            @Override
            public void ensureHeavy( RelationshipGroupRecord record )
            {   // Not needed
            }

            @Override
            public RelationshipGroupRecord clone( RelationshipGroupRecord record ) throws CloneNotSupportedException
            {
                return record.clone();
            }
        };
    }

Replace Generic With Diamond Loader<RelationshipGroupRecord,Integer> with Loader<> in method public relationshipGroupLoader(store RecordStore<RelationshipGroupRecord>) : Loader<RelationshipGroupRecord,Integer> from class org.neo4j.internal.recordstorage.Loaders


    private static Loader<SchemaRecord, SchemaRule> schemaRuleLoader( final SchemaStore store )
    {
        return new Loader<>()
        {
            @Override
            public SchemaRecord newUnused( long key, SchemaRule additionalData )
            {
                return andMarkAsCreated( new SchemaRecord( key ) );
            }

            @Override
            public SchemaRecord load( long key, SchemaRule additionalData )
            {
                return store.getRecord( key, store.newRecord(), RecordLoad.NORMAL );
            }

            @Override
            public void ensureHeavy( SchemaRecord record )
            {
            }

            @Override
            public SchemaRecord clone( SchemaRecord record ) throws CloneNotSupportedException
            {
                return record.clone();
            }
        };
    }

    private static Loader<SchemaRecord, SchemaRule> schemaRuleLoader( final SchemaStore store )
    {
        return new Loader<SchemaRecord, SchemaRule>()
        {
            @Override
            public SchemaRecord newUnused( long key, SchemaRule additionalData )
            {
                return andMarkAsCreated( new SchemaRecord( key ) );
            }

            @Override
            public SchemaRecord load( long key, SchemaRule additionalData )
            {
                return store.getRecord( key, store.newRecord(), RecordLoad.NORMAL );
            }

            @Override
            public void ensureHeavy( SchemaRecord record )
            {
            }

            @Override
            public SchemaRecord clone( SchemaRecord record ) throws CloneNotSupportedException
            {
                return record.clone();
            }
        };
    }

Replace Generic With Diamond Loader<SchemaRecord,SchemaRule> with Loader<> in method private schemaRuleLoader(store SchemaStore) : Loader<SchemaRecord,SchemaRule> from class org.neo4j.internal.recordstorage.Loaders


    public static Loader<PropertyKeyTokenRecord,Void> propertyKeyTokenLoader(
            final RecordStore<PropertyKeyTokenRecord> store )
    {
        return new Loader<>()
        {
            @Override
            public PropertyKeyTokenRecord newUnused( long key, Void additionalData )
            {
                return andMarkAsCreated( new PropertyKeyTokenRecord( toIntExact( key ) ) );
            }

            @Override
            public PropertyKeyTokenRecord load( long key, Void additionalData )
            {
                return store.getRecord( key, store.newRecord(), NORMAL );
            }

            @Override
            public void ensureHeavy( PropertyKeyTokenRecord record )
            {
                store.ensureHeavy( record );
            }

            @Override
            public PropertyKeyTokenRecord clone( PropertyKeyTokenRecord record ) throws CloneNotSupportedException
            {
                return record.clone();
            }
        };
    }

    public static Loader<PropertyKeyTokenRecord,Void> propertyKeyTokenLoader(
            final RecordStore<PropertyKeyTokenRecord> store )
    {
        return new Loader<PropertyKeyTokenRecord, Void>()
        {
            @Override
            public PropertyKeyTokenRecord newUnused( long key, Void additionalData )
            {
                return andMarkAsCreated( new PropertyKeyTokenRecord( toIntExact( key ) ) );
            }

            @Override
            public PropertyKeyTokenRecord load( long key, Void additionalData )
            {
                return store.getRecord( key, store.newRecord(), NORMAL );
            }

            @Override
            public void ensureHeavy( PropertyKeyTokenRecord record )
            {
                store.ensureHeavy( record );
            }

            @Override
            public PropertyKeyTokenRecord clone( PropertyKeyTokenRecord record ) throws CloneNotSupportedException
            {
                return record.clone();
            }
        };
    }

Replace Generic With Diamond Loader<PropertyKeyTokenRecord,Void> with Loader<> in method public propertyKeyTokenLoader(store RecordStore<PropertyKeyTokenRecord>) : Loader<PropertyKeyTokenRecord,Void> from class org.neo4j.internal.recordstorage.Loaders


    public static Loader<LabelTokenRecord,Void> labelTokenLoader(
            final RecordStore<LabelTokenRecord> store )
    {
        return new Loader<>()
        {
            @Override
            public LabelTokenRecord newUnused( long key, Void additionalData )
            {
                return andMarkAsCreated( new LabelTokenRecord( toIntExact( key ) ) );
            }

            @Override
            public LabelTokenRecord load( long key, Void additionalData )
            {
                return store.getRecord( key, store.newRecord(), NORMAL );
            }

            @Override
            public void ensureHeavy( LabelTokenRecord record )
            {
                store.ensureHeavy( record );
            }

            @Override
            public LabelTokenRecord clone( LabelTokenRecord record ) throws CloneNotSupportedException
            {
                return record.clone();
            }
        };
    }

    public static Loader<LabelTokenRecord,Void> labelTokenLoader(
            final RecordStore<LabelTokenRecord> store )
    {
        return new Loader<LabelTokenRecord, Void>()
        {
            @Override
            public LabelTokenRecord newUnused( long key, Void additionalData )
            {
                return andMarkAsCreated( new LabelTokenRecord( toIntExact( key ) ) );
            }

            @Override
            public LabelTokenRecord load( long key, Void additionalData )
            {
                return store.getRecord( key, store.newRecord(), NORMAL );
            }

            @Override
            public void ensureHeavy( LabelTokenRecord record )
            {
                store.ensureHeavy( record );
            }

            @Override
            public LabelTokenRecord clone( LabelTokenRecord record ) throws CloneNotSupportedException
            {
                return record.clone();
            }
        };
    }

Replace Generic With Diamond Loader<LabelTokenRecord,Void> with Loader<> in method public labelTokenLoader(store RecordStore<LabelTokenRecord>) : Loader<LabelTokenRecord,Void> from class org.neo4j.internal.recordstorage.Loaders


    public static Loader<RelationshipTypeTokenRecord,Void> relationshipTypeTokenLoader(
            final RecordStore<RelationshipTypeTokenRecord> store )
    {
        return new Loader<>()
        {
            @Override
            public RelationshipTypeTokenRecord newUnused( long key, Void additionalData )
            {
                return andMarkAsCreated( new RelationshipTypeTokenRecord( toIntExact( key ) ) );
            }

            @Override
            public RelationshipTypeTokenRecord load( long key, Void additionalData )
            {
                return store.getRecord( key, store.newRecord(), NORMAL );
            }

            @Override
            public void ensureHeavy( RelationshipTypeTokenRecord record )
            {
                store.ensureHeavy( record );
            }

            @Override
            public RelationshipTypeTokenRecord clone( RelationshipTypeTokenRecord record ) throws CloneNotSupportedException
            {
                return record.clone();
            }
        };
    }

    public static Loader<RelationshipTypeTokenRecord,Void> relationshipTypeTokenLoader(
            final RecordStore<RelationshipTypeTokenRecord> store )
    {
        return new Loader<RelationshipTypeTokenRecord, Void>()
        {
            @Override
            public RelationshipTypeTokenRecord newUnused( long key, Void additionalData )
            {
                return andMarkAsCreated( new RelationshipTypeTokenRecord( toIntExact( key ) ) );
            }

            @Override
            public RelationshipTypeTokenRecord load( long key, Void additionalData )
            {
                return store.getRecord( key, store.newRecord(), NORMAL );
            }

            @Override
            public void ensureHeavy( RelationshipTypeTokenRecord record )
            {
                store.ensureHeavy( record );
            }

            @Override
            public RelationshipTypeTokenRecord clone( RelationshipTypeTokenRecord record ) throws CloneNotSupportedException
            {
                return record.clone();
            }
        };
    }

Replace Generic With Diamond Loader<RelationshipTypeTokenRecord,Void> with Loader<> in method public relationshipTypeTokenLoader(store RecordStore<RelationshipTypeTokenRecord>) : Loader<RelationshipTypeTokenRecord,Void> from class org.neo4j.internal.recordstorage.Loaders


    private static RecordStore<DynamicRecord> wrapNodeDynamicLabelStore( RecordStore<DynamicRecord> store )
    {
        return new RecordStore.Delegator<>( store )
        {
            @Override
            public <FAILURE extends Exception> void accept( Processor<FAILURE> processor, DynamicRecord record )
                    throws FAILURE
            {
                processor.processLabelArrayWithOwner( this, record );
            }
        };
    }

    private static RecordStore<DynamicRecord> wrapNodeDynamicLabelStore( RecordStore<DynamicRecord> store )
    {
        return new RecordStore.Delegator<DynamicRecord>( store )
        {
            @Override
            public <FAILURE extends Exception> void accept( Processor<FAILURE> processor, DynamicRecord record )
                    throws FAILURE
            {
                processor.processLabelArrayWithOwner( this, record );
            }
        };
    }

Replace Generic With Diamond RecordStore.Delegator<DynamicRecord> with RecordStore.Delegator<> in method private wrapNodeDynamicLabelStore(store RecordStore<DynamicRecord>) : RecordStore<DynamicRecord> from class org.neo4j.kernel.impl.store.StoreAccess


    public CountsTracker setInitializer( final DataInitializer<Updater> initializer )
    {
        setEntryUpdaterInitializer( new DataInitializer<>()
        {
            @Override
            public void initialize( EntryUpdater<CountsKey> updater )
            {
                initializer.initialize( new CountsUpdater( updater ) );
            }

            @Override
            public long initialVersion()
            {
                return initializer.initialVersion();
            }
        } );
        return this;
    }

    public CountsTracker setInitializer( final DataInitializer<Updater> initializer )
    {
        setEntryUpdaterInitializer( new DataInitializer<EntryUpdater<CountsKey>>()
        {
            @Override
            public void initialize( EntryUpdater<CountsKey> updater )
            {
                initializer.initialize( new CountsUpdater( updater ) );
            }

            @Override
            public long initialVersion()
            {
                return initializer.initialVersion();
            }
        } );
        return this;
    }

Replace Generic With Diamond DataInitializer<EntryUpdater<CountsKey>> with DataInitializer<> in method public setInitializer(initializer DataInitializer<Updater>) : CountsTracker from class org.neo4j.kernel.impl.store.counts.CountsTracker


    @Override
    protected EntryUpdater<Key> resettingUpdater( Lock lock, final Runnable closeAction )
    {
        if ( hasChanges() )
        {
            throw new IllegalStateException( "Cannot reset when there are changes!" );
        }
        return new EntryUpdater<>( lock )
        {
            @Override
            public void apply( Key key, ValueUpdate update ) throws IOException
            {
                ensureOpen();
                applyUpdate( store, changes, key, update, true, highestAppliedVersion.get() );
            }

            @Override
            public void close()
            {
                try
                {
                    closeAction.run();
                }
                finally
                {
                    super.close();
                }
            }
        };
    }

    @Override
    protected EntryUpdater<Key> resettingUpdater( Lock lock, final Runnable closeAction )
    {
        if ( hasChanges() )
        {
            throw new IllegalStateException( "Cannot reset when there are changes!" );
        }
        return new EntryUpdater<Key>( lock )
        {
            @Override
            public void apply( Key key, ValueUpdate update ) throws IOException
            {
                ensureOpen();
                applyUpdate( store, changes, key, update, true, highestAppliedVersion.get() );
            }

            @Override
            public void close()
            {
                try
                {
                    closeAction.run();
                }
                finally
                {
                    super.close();
                }
            }
        };
    }

Replace Generic With Diamond EntryUpdater<Key> with EntryUpdater<> in method protected resettingUpdater(lock Lock, closeAction Runnable) : EntryUpdater<Key> from class org.neo4j.kernel.impl.store.kvstore.ConcurrentMapState


    static <Sink> DataInitializer<Sink> empty( long initialTxId )
    {
        return new DataInitializer<>()
        {
            @Override
            public void initialize( Sink sink )
            {
            }

            @Override
            public long initialVersion()
            {
                return initialTxId;
            }
        };
    }

    static <Sink> DataInitializer<Sink> empty( long initialTxId )
    {
        return new DataInitializer<Sink>()
        {
            @Override
            public void initialize( Sink sink )
            {
            }

            @Override
            public long initialVersion()
            {
                return initialTxId;
            }
        };
    }

Replace Generic With Diamond DataInitializer<Sink> with DataInitializer<> in method public empty(initialTxId long) : DataInitializer<Sink> from class org.neo4j.kernel.impl.store.kvstore.DataInitializer


        /** for rotating recovered state (none) */
        @Override
        RotationState<Key> prepareRotation( long version )
        {
            return new Rotation<>( this )
            {
                @Override
                ProgressiveState<Key> rotate( boolean force, RotationStrategy strategy, RotationTimerFactory timerFactory,
                                              Consumer<Headers.Builder> headers )
                {
                    return state;
                }

                @Override
                public void close()
                {
                }

                @Override
                long rotationVersion()
                {
                    return state.version();
                }

                @Override
                ProgressiveState<Key> markAsFailed()
                {
                    return this;
                }
            };
        }

        /** for rotating recovered state (none) */
        @Override
        RotationState<Key> prepareRotation( long version )
        {
            return new Rotation<Key, NeedsCreation<Key>>( this )
            {
                @Override
                ProgressiveState<Key> rotate( boolean force, RotationStrategy strategy, RotationTimerFactory timerFactory,
                                              Consumer<Headers.Builder> headers )
                {
                    return state;
                }

                @Override
                public void close()
                {
                }

                @Override
                long rotationVersion()
                {
                    return state.version();
                }

                @Override
                ProgressiveState<Key> markAsFailed()
                {
                    return this;
                }
            };
        }

Replace Generic With Diamond Rotation<Key,NeedsCreation<Key>> with Rotation<> in method package prepareRotation(version long) : RotationState<Key> from class org.neo4j.kernel.impl.store.kvstore.DeadState.NeedsCreation


        /** for rotating recovered state */
        @Override
        RotationState<Key> prepareRotation( long version )
        {
            return new Rotation<>( state.prepareRotation( version ) )
            {
                @Override
                ProgressiveState<Key> rotate( boolean force, RotationStrategy strategy, RotationTimerFactory timerFactory,
                                              Consumer<Headers.Builder> headers ) throws IOException
                {
                    return new Prepared<>( state.rotate( force, strategy, timerFactory, headers ) );
                }

                @Override
                public void close() throws IOException
                {
                    state.close();
                }

                @Override
                long rotationVersion()
                {
                    return state.rotationVersion();
                }

                @Override
                ProgressiveState<Key> markAsFailed()
                {
                    return state;
                }
            };
        }

        /** for rotating recovered state */
        @Override
        RotationState<Key> prepareRotation( long version )
        {
            return new Rotation<Key, RotationState.Rotation<Key>>( state.prepareRotation( version ) )
            {
                @Override
                ProgressiveState<Key> rotate( boolean force, RotationStrategy strategy, RotationTimerFactory timerFactory,
                                              Consumer<Headers.Builder> headers ) throws IOException
                {
                    return new Prepared<>( state.rotate( force, strategy, timerFactory, headers ) );
                }

                @Override
                public void close() throws IOException
                {
                    state.close();
                }

                @Override
                long rotationVersion()
                {
                    return state.rotationVersion();
                }

                @Override
                ProgressiveState<Key> markAsFailed()
                {
                    return state;
                }
            };
        }

Replace Generic With Diamond Rotation<Key,RotationState.Rotation<Key>> with Rotation<> in method package prepareRotation(version long) : RotationState<Key> from class org.neo4j.kernel.impl.store.kvstore.DeadState.Prepared


    static <Key> ReadableState<Key> store( final KeyFormat<Key> keys, final KeyValueStoreFile store )
    {
        return new ReadableState<>()
        {
            @Override
            protected KeyFormat<Key> keyFormat()
            {
                return keys;
            }

            @Override
            protected Headers headers()
            {
                return store.headers();
            }

            @Override
            protected long version()
            {
                return keys.version( headers() ); // TODO: 'keys' is not the right guy to have this responsibility
            }

            @Override
            protected boolean lookup( Key key, ValueSink sink ) throws IOException
            {
                return store.scan( new KeyFormat.Searcher<>( keys, key ), sink );
            }

            @Override
            protected DataProvider dataProvider() throws IOException
            {
                return store.dataProvider();
            }

            @Override
            protected int storedEntryCount()
            {
                return store.entryCount();
            }

            @Override
            public void close() throws IOException
            {
                store.close();
            }
        };
    }

    static <Key> ReadableState<Key> store( final KeyFormat<Key> keys, final KeyValueStoreFile store )
    {
        return new ReadableState<Key>()
        {
            @Override
            protected KeyFormat<Key> keyFormat()
            {
                return keys;
            }

            @Override
            protected Headers headers()
            {
                return store.headers();
            }

            @Override
            protected long version()
            {
                return keys.version( headers() ); // TODO: 'keys' is not the right guy to have this responsibility
            }

            @Override
            protected boolean lookup( Key key, ValueSink sink ) throws IOException
            {
                return store.scan( new KeyFormat.Searcher<>( keys, key ), sink );
            }

            @Override
            protected DataProvider dataProvider() throws IOException
            {
                return store.dataProvider();
            }

            @Override
            protected int storedEntryCount()
            {
                return store.entryCount();
            }

            @Override
            public void close() throws IOException
            {
                store.close();
            }
        };
    }

Replace Generic With Diamond ReadableState<Key> with ReadableState<> in method package store(keys KeyFormat<Key>, store KeyValueStoreFile) : ReadableState<Key> from class org.neo4j.kernel.impl.store.kvstore.ReadableState


    static <Key> ReadableState<Key> empty( final KeyFormat<Key> keys, final long version )
    {
        return new ReadableState<>()
        {
            @Override
            protected KeyFormat<Key> keyFormat()
            {
                return keys;
            }

            @Override
            protected Headers headers()
            {
                return null;
            }

            @Override
            protected long version()
            {
                return version;
            }

            @Override
            protected boolean lookup( Key key, ValueSink sink )
            {
                return false;
            }

            @Override
            protected DataProvider dataProvider()
            {
                return EMPTY_DATA_PROVIDER;
            }

            @Override
            protected int storedEntryCount()
            {
                return 0;
            }

            @Override
            public void close()
            {
            }
        };
    }

    static <Key> ReadableState<Key> empty( final KeyFormat<Key> keys, final long version )
    {
        return new ReadableState<Key>()
        {
            @Override
            protected KeyFormat<Key> keyFormat()
            {
                return keys;
            }

            @Override
            protected Headers headers()
            {
                return null;
            }

            @Override
            protected long version()
            {
                return version;
            }

            @Override
            protected boolean lookup( Key key, ValueSink sink )
            {
                return false;
            }

            @Override
            protected DataProvider dataProvider()
            {
                return EMPTY_DATA_PROVIDER;
            }

            @Override
            protected int storedEntryCount()
            {
                return 0;
            }

            @Override
            public void close()
            {
            }
        };
    }

Replace Generic With Diamond ReadableState<Key> with ReadableState<> in method package empty(keys KeyFormat<Key>, version long) : ReadableState<Key> from class org.neo4j.kernel.impl.store.kvstore.ReadableState


        @Override
        protected Optional<EntryUpdater<Key>> optionalUpdater( long version, Lock lock )
        {
            final EntryUpdater<Key> post = postState.updater( version, lock );
            if ( version <= threshold )
            {
                final EntryUpdater<Key> pre = preState.updater( version, lock );
                return Optional.of( new EntryUpdater<>( lock )
                {
                    @Override
                    public void apply( Key key, ValueUpdate update ) throws IOException
                    {
                        // Apply to the postState first, so that if the postState needs to read the state from the preState
                        // it will read the value prior to this update, then subsequent updates to the postState will not
                        // have to read from preState, ensuring that each update is applied exactly once to both preState
                        // and postState, which together with the commutativity of updates ensures consistent outcomes.
                        post.apply( key, update );
                        pre.apply( key, update );
                    }

                    @Override
                    public void close()
                    {
                        post.close();
                        pre.close();
                        super.close();
                    }
                } );
            }
            else
            {
                return Optional.of( post );
            }
        }

        @Override
        protected Optional<EntryUpdater<Key>> optionalUpdater( long version, Lock lock )
        {
            final EntryUpdater<Key> post = postState.updater( version, lock );
            if ( version <= threshold )
            {
                final EntryUpdater<Key> pre = preState.updater( version, lock );
                return Optional.of( new EntryUpdater<Key>( lock )
                {
                    @Override
                    public void apply( Key key, ValueUpdate update ) throws IOException
                    {
                        // Apply to the postState first, so that if the postState needs to read the state from the preState
                        // it will read the value prior to this update, then subsequent updates to the postState will not
                        // have to read from preState, ensuring that each update is applied exactly once to both preState
                        // and postState, which together with the commutativity of updates ensures consistent outcomes.
                        post.apply( key, update );
                        pre.apply( key, update );
                    }

                    @Override
                    public void close()
                    {
                        post.close();
                        pre.close();
                        super.close();
                    }
                } );
            }
            else
            {
                return Optional.of( post );
            }
        }

Replace Generic With Diamond EntryUpdater<Key> with EntryUpdater<> in method protected optionalUpdater(version long, lock Lock) : Optional<EntryUpdater<Key>> from class org.neo4j.kernel.impl.store.kvstore.RotationState.Rotation


    @Override
    public Iterator<PropertyBlock> iterator()
    {
        ensureBlocksLoaded();
        return new Iterator<>()
        {
            // state for the Iterator aspect of this class.
            private int blockRecordsIteratorCursor;
            private boolean canRemoveFromIterator;

            @Override
            public boolean hasNext()
            {
                return blockRecordsIteratorCursor < blockRecordsCursor;
            }

            @Override
            public PropertyBlock next()
            {
                if ( !hasNext() )
                {
                    throw new NoSuchElementException();
                }
                canRemoveFromIterator = true;
                return blockRecords[blockRecordsIteratorCursor++];
            }

            @Override
            public void remove()
            {
                if ( !canRemoveFromIterator )
                {
                    throw new IllegalStateException(
                            "cursor:" + blockRecordsIteratorCursor + " canRemove:" + canRemoveFromIterator );
                }

                if ( --blockRecordsCursor > --blockRecordsIteratorCursor )
                {
                    blockRecords[blockRecordsIteratorCursor] = blockRecords[blockRecordsCursor];
                }
                canRemoveFromIterator = false;
            }
        };
    }

    @Override
    public Iterator<PropertyBlock> iterator()
    {
        ensureBlocksLoaded();
        return new Iterator<PropertyBlock>()
        {
            // state for the Iterator aspect of this class.
            private int blockRecordsIteratorCursor;
            private boolean canRemoveFromIterator;

            @Override
            public boolean hasNext()
            {
                return blockRecordsIteratorCursor < blockRecordsCursor;
            }

            @Override
            public PropertyBlock next()
            {
                if ( !hasNext() )
                {
                    throw new NoSuchElementException();
                }
                canRemoveFromIterator = true;
                return blockRecords[blockRecordsIteratorCursor++];
            }

            @Override
            public void remove()
            {
                if ( !canRemoveFromIterator )
                {
                    throw new IllegalStateException(
                            "cursor:" + blockRecordsIteratorCursor + " canRemove:" + canRemoveFromIterator );
                }

                if ( --blockRecordsCursor > --blockRecordsIteratorCursor )
                {
                    blockRecords[blockRecordsIteratorCursor] = blockRecords[blockRecordsCursor];
                }
                canRemoveFromIterator = false;
            }
        };
    }

Replace Generic With Diamond Iterator<PropertyBlock> with Iterator<> in method public iterator() : Iterator<PropertyBlock> from class org.neo4j.kernel.impl.store.record.PropertyRecord


    /**
     * Scans the schema store and loads all {@link SchemaRule rules} in it. This method is written with the assumption
     * that there's no id reuse on schema records.
     *
     * @param predicate filter when loading.
     * @param returnType type of {@link SchemaRule} to load.
     * @return {@link Iterator} of the loaded schema rules, lazily loaded when advancing the iterator.
     */
    private <ReturnType extends SchemaRule> Iterator<ReturnType> loadAllSchemaRules( final Predicate<ReturnType> predicate, final Class<ReturnType> returnType )
    {
        return new PrefetchingIterator<>()
        {
            private final long highestId = schemaStore.getHighestPossibleIdInUse();
            private long currentId = 1; /*record 0 contains the block size*/
            private final byte[] scratchData = newRecordBuffer();
            private final DynamicRecord record = schemaStore.newRecord();

            @Override
            protected ReturnType fetchNextOrNull()
            {
                while ( currentId <= highestId )
                {
                    long id = currentId++;
                    schemaStore.getRecord( id, record, RecordLoad.FORCE );
                    if ( record.inUse() && record.isStartRecord() )
                    {
                        // It may be that concurrently to our reading there's a transaction dropping the schema rule
                        // that we're reading and that rule may have spanned multiple dynamic records.
                        try
                        {
                            Collection<DynamicRecord> records;
                            try
                            {
                                records = schemaStore.getRecords( id, RecordLoad.NORMAL, false );
                            }
                            catch ( InvalidRecordException e )
                            {
                                // This may have been due to a concurrent drop of this rule.
                                continue;
                            }

                            SchemaRule schemaRule = SchemaStore35.readSchemaRule( id, records, scratchData );
                            if ( returnType.isInstance( schemaRule ) )
                            {
                                ReturnType returnRule = returnType.cast( schemaRule );
                                if ( predicate.test( returnRule ) )
                                {
                                    return returnRule;
                                }
                            }
                        }
                        catch ( MalformedSchemaRuleException e )
                        {
                            throw new RuntimeException( e );
                        }
                    }
                }
                return null;
            }
        };
    }

    /**
     * Scans the schema store and loads all {@link SchemaRule rules} in it. This method is written with the assumption
     * that there's no id reuse on schema records.
     *
     * @param predicate filter when loading.
     * @param returnType type of {@link SchemaRule} to load.
     * @return {@link Iterator} of the loaded schema rules, lazily loaded when advancing the iterator.
     */
    private <ReturnType extends SchemaRule> Iterator<ReturnType> loadAllSchemaRules( final Predicate<ReturnType> predicate, final Class<ReturnType> returnType )
    {
        return new PrefetchingIterator<ReturnType>()
        {
            private final long highestId = schemaStore.getHighestPossibleIdInUse();
            private long currentId = 1; /*record 0 contains the block size*/
            private final byte[] scratchData = newRecordBuffer();
            private final DynamicRecord record = schemaStore.newRecord();

            @Override
            protected ReturnType fetchNextOrNull()
            {
                while ( currentId <= highestId )
                {
                    long id = currentId++;
                    schemaStore.getRecord( id, record, RecordLoad.FORCE );
                    if ( record.inUse() && record.isStartRecord() )
                    {
                        // It may be that concurrently to our reading there's a transaction dropping the schema rule
                        // that we're reading and that rule may have spanned multiple dynamic records.
                        try
                        {
                            Collection<DynamicRecord> records;
                            try
                            {
                                records = schemaStore.getRecords( id, RecordLoad.NORMAL, false );
                            }
                            catch ( InvalidRecordException e )
                            {
                                // This may have been due to a concurrent drop of this rule.
                                continue;
                            }

                            SchemaRule schemaRule = SchemaStore35.readSchemaRule( id, records, scratchData );
                            if ( returnType.isInstance( schemaRule ) )
                            {
                                ReturnType returnRule = returnType.cast( schemaRule );
                                if ( predicate.test( returnRule ) )
                                {
                                    return returnRule;
                                }
                            }
                        }
                        catch ( MalformedSchemaRuleException e )
                        {
                            throw new RuntimeException( e );
                        }
                    }
                }
                return null;
            }
        };
    }

Replace Generic With Diamond PrefetchingIterator<ReturnType> with PrefetchingIterator<> in method private loadAllSchemaRules(predicate Predicate<ReturnType>, returnType Class<ReturnType>) : Iterator<ReturnType> from class org.neo4j.kernel.impl.storemigration.legacy.SchemaStorage35


        @Override
        public Iterator<T> iterator()
        {
            return new Iterator<>()
            {
                final int size = length();
                int pos;

                @Override
                public boolean hasNext()
                {
                    return pos < size;
                }

                @Override
                public T next()
                {
                    return item( pos++ );
                }

                @Override
                public void remove()
                {
                    throw new UnsupportedOperationException(
                            "Cannot remove element from primitive array." );
                }
            };
        }

        @Override
        public Iterator<T> iterator()
        {
            return new Iterator<T>()
            {
                final int size = length();
                int pos;

                @Override
                public boolean hasNext()
                {
                    return pos < size;
                }

                @Override
                public T next()
                {
                    return item( pos++ );
                }

                @Override
                public void remove()
                {
                    throw new UnsupportedOperationException(
                            "Cannot remove element from primitive array." );
                }
            };
        }

Replace Generic With Diamond Iterator<T> with Iterator<> in method public iterator() : Iterator<T> from class org.neo4j.server.helpers.PropertyTypeDispatcher.PrimitiveArray


    protected T dispatchByteArrayProperty( final byte[] property, K param )
    {
        return dispatchByteArrayProperty( new PrimitiveArray<>()
        {
            @Override
            public byte[] getClonedArray()
            {
                return property.clone();
            }

            @Override
            public int length()
            {
                return property.length;
            }

            @Override
            @SuppressWarnings( "boxing" )
            protected Byte item( int offset )
            {
                return property[offset];
            }

            @Override
            public Class<?> getType()
            {
                return property.getClass();
            }
        }, param );
    }

    protected T dispatchByteArrayProperty( final byte[] property, K param )
    {
        return dispatchByteArrayProperty( new PrimitiveArray<byte[], Byte>()
        {
            @Override
            public byte[] getClonedArray()
            {
                return property.clone();
            }

            @Override
            public int length()
            {
                return property.length;
            }

            @Override
            @SuppressWarnings( "boxing" )
            protected Byte item( int offset )
            {
                return property[offset];
            }

            @Override
            public Class<?> getType()
            {
                return property.getClass();
            }
        }, param );
    }

Replace Generic With Diamond PrimitiveArray<byte[],Byte> with PrimitiveArray<> in method protected dispatchByteArrayProperty(property byte[], param K) : T from class org.neo4j.server.helpers.PropertyTypeDispatcher


    protected T dispatchCharacterArrayProperty( final char[] property, K param )
    {
        return dispatchCharacterArrayProperty( new PrimitiveArray<>()
        {
            @Override
            public char[] getClonedArray()
            {
                return property.clone();
            }

            @Override
            public int length()
            {
                return property.length;
            }

            @Override
            @SuppressWarnings( "boxing" )
            protected Character item( int offset )
            {
                return property[offset];
            }

            @Override
            public Class<?> getType()
            {
                return property.getClass();
            }
        }, param );
    }

    protected T dispatchCharacterArrayProperty( final char[] property, K param )
    {
        return dispatchCharacterArrayProperty( new PrimitiveArray<char[], Character>()
        {
            @Override
            public char[] getClonedArray()
            {
                return property.clone();
            }

            @Override
            public int length()
            {
                return property.length;
            }

            @Override
            @SuppressWarnings( "boxing" )
            protected Character item( int offset )
            {
                return property[offset];
            }

            @Override
            public Class<?> getType()
            {
                return property.getClass();
            }
        }, param );
    }

Replace Generic With Diamond PrimitiveArray<char[],Character> with PrimitiveArray<> in method protected dispatchCharacterArrayProperty(property char[], param K) : T from class org.neo4j.server.helpers.PropertyTypeDispatcher


    protected T dispatchShortArrayProperty( final short[] property, K param )
    {
        return dispatchShortArrayProperty( new PrimitiveArray<>()
        {
            @Override
            public short[] getClonedArray()
            {
                return property.clone();
            }

            @Override
            public int length()
            {
                return property.length;
            }

            @Override
            @SuppressWarnings( "boxing" )
            protected Short item( int offset )
            {
                return property[offset];
            }

            @Override
            public Class<?> getType()
            {
                return property.getClass();
            }
        }, param );
    }

    protected T dispatchShortArrayProperty( final short[] property, K param )
    {
        return dispatchShortArrayProperty( new PrimitiveArray<short[], Short>()
        {
            @Override
            public short[] getClonedArray()
            {
                return property.clone();
            }

            @Override
            public int length()
            {
                return property.length;
            }

            @Override
            @SuppressWarnings( "boxing" )
            protected Short item( int offset )
            {
                return property[offset];
            }

            @Override
            public Class<?> getType()
            {
                return property.getClass();
            }
        }, param );
    }

Replace Generic With Diamond PrimitiveArray<short[],Short> with PrimitiveArray<> in method protected dispatchShortArrayProperty(property short[], param K) : T from class org.neo4j.server.helpers.PropertyTypeDispatcher


    protected T dispatchIntegerArrayProperty( final int[] property, K param )
    {
        return dispatchIntegerArrayProperty( new PrimitiveArray<>()
        {
            @Override
            public int[] getClonedArray()
            {
                return property.clone();
            }

            @Override
            public int length()
            {
                return property.length;
            }

            @Override
            @SuppressWarnings( "boxing" )
            protected Integer item( int offset )
            {
                return property[offset];
            }

            @Override
            public Class<?> getType()
            {
                return property.getClass();
            }
        }, param );
    }

    protected T dispatchIntegerArrayProperty( final int[] property, K param )
    {
        return dispatchIntegerArrayProperty( new PrimitiveArray<int[], Integer>()
        {
            @Override
            public int[] getClonedArray()
            {
                return property.clone();
            }

            @Override
            public int length()
            {
                return property.length;
            }

            @Override
            @SuppressWarnings( "boxing" )
            protected Integer item( int offset )
            {
                return property[offset];
            }

            @Override
            public Class<?> getType()
            {
                return property.getClass();
            }
        }, param );
    }

Replace Generic With Diamond PrimitiveArray<int[],Integer> with PrimitiveArray<> in method protected dispatchIntegerArrayProperty(property int[], param K) : T from class org.neo4j.server.helpers.PropertyTypeDispatcher


    protected T dispatchLongArrayProperty( final long[] property, K param )
    {
        return dispatchLongArrayProperty( new PrimitiveArray<>()
        {
            @Override
            public long[] getClonedArray()
            {
                return property.clone();
            }

            @Override
            public int length()
            {
                return property.length;
            }

            @Override
            @SuppressWarnings( "boxing" )
            protected Long item( int offset )
            {
                return property[offset];
            }

            @Override
            public Class<?> getType()
            {
                return property.getClass();
            }
        }, param );
    }

    protected T dispatchLongArrayProperty( final long[] property, K param )
    {
        return dispatchLongArrayProperty( new PrimitiveArray<long[], Long>()
        {
            @Override
            public long[] getClonedArray()
            {
                return property.clone();
            }

            @Override
            public int length()
            {
                return property.length;
            }

            @Override
            @SuppressWarnings( "boxing" )
            protected Long item( int offset )
            {
                return property[offset];
            }

            @Override
            public Class<?> getType()
            {
                return property.getClass();
            }
        }, param );
    }

Replace Generic With Diamond PrimitiveArray<long[],Long> with PrimitiveArray<> in method protected dispatchLongArrayProperty(property long[], param K) : T from class org.neo4j.server.helpers.PropertyTypeDispatcher


    protected T dispatchFloatArrayProperty( final float[] property, K param )
    {
        return dispatchFloatArrayProperty( new PrimitiveArray<>()
        {
            @Override
            public float[] getClonedArray()
            {
                return property.clone();
            }

            @Override
            public int length()
            {
                return property.length;
            }

            @Override
            @SuppressWarnings( "boxing" )
            protected Float item( int offset )
            {
                return property[offset];
            }

            @Override
            public Class<?> getType()
            {
                return property.getClass();
            }
        }, param );
    }

    protected T dispatchFloatArrayProperty( final float[] property, K param )
    {
        return dispatchFloatArrayProperty( new PrimitiveArray<float[], Float>()
        {
            @Override
            public float[] getClonedArray()
            {
                return property.clone();
            }

            @Override
            public int length()
            {
                return property.length;
            }

            @Override
            @SuppressWarnings( "boxing" )
            protected Float item( int offset )
            {
                return property[offset];
            }

            @Override
            public Class<?> getType()
            {
                return property.getClass();
            }
        }, param );
    }

Replace Generic With Diamond PrimitiveArray<float[],Float> with PrimitiveArray<> in method protected dispatchFloatArrayProperty(property float[], param K) : T from class org.neo4j.server.helpers.PropertyTypeDispatcher


    protected T dispatchDoubleArrayProperty( final double[] property, K param )
    {
        return dispatchDoubleArrayProperty( new PrimitiveArray<>()
        {
            @Override
            public double[] getClonedArray()
            {
                return property.clone();
            }

            @Override
            public int length()
            {
                return property.length;
            }

            @Override
            @SuppressWarnings( "boxing" )
            protected Double item( int offset )
            {
                return property[offset];
            }

            @Override
            public Class<?> getType()
            {
                return property.getClass();
            }
        }, param );
    }

    protected T dispatchDoubleArrayProperty( final double[] property, K param )
    {
        return dispatchDoubleArrayProperty( new PrimitiveArray<double[], Double>()
        {
            @Override
            public double[] getClonedArray()
            {
                return property.clone();
            }

            @Override
            public int length()
            {
                return property.length;
            }

            @Override
            @SuppressWarnings( "boxing" )
            protected Double item( int offset )
            {
                return property[offset];
            }

            @Override
            public Class<?> getType()
            {
                return property.getClass();
            }
        }, param );
    }

Replace Generic With Diamond PrimitiveArray<double[],Double> with PrimitiveArray<> in method protected dispatchDoubleArrayProperty(property double[], param K) : T from class org.neo4j.server.helpers.PropertyTypeDispatcher


    protected T dispatchBooleanArrayProperty( final boolean[] property, K param )
    {
        return dispatchBooleanArrayProperty( new PrimitiveArray<>()
        {
            @Override
            public boolean[] getClonedArray()
            {
                return property.clone();
            }

            @Override
            public int length()
            {
                return property.length;
            }

            @Override
            @SuppressWarnings( "boxing" )
            protected Boolean item( int offset )
            {
                return property[offset];
            }

            @Override
            public Class<?> getType()
            {
                return property.getClass();
            }
        }, param );
    }

    protected T dispatchBooleanArrayProperty( final boolean[] property, K param )
    {
        return dispatchBooleanArrayProperty( new PrimitiveArray<boolean[], Boolean>()
        {
            @Override
            public boolean[] getClonedArray()
            {
                return property.clone();
            }

            @Override
            public int length()
            {
                return property.length;
            }

            @Override
            @SuppressWarnings( "boxing" )
            protected Boolean item( int offset )
            {
                return property[offset];
            }

            @Override
            public Class<?> getType()
            {
                return property.getClass();
            }
        }, param );
    }

Replace Generic With Diamond PrimitiveArray<boolean[],Boolean> with PrimitiveArray<> in method protected dispatchBooleanArrayProperty(property boolean[], param K) : T from class org.neo4j.server.helpers.PropertyTypeDispatcher


    protected T dispatchStringArrayProperty( final String[] property, K param )
    {
        return dispatchStringArrayProperty( new BoxedArray<>( property )
        {
            @Override
            public String[] getClonedArray()
            {
                return property.clone();
            }
        }, param );
    }

    protected T dispatchStringArrayProperty( final String[] property, K param )
    {
        return dispatchStringArrayProperty( new BoxedArray<String[], String>( property )
        {
            @Override
            public String[] getClonedArray()
            {
                return property.clone();
            }
        }, param );
    }

Replace Generic With Diamond BoxedArray<String[],String> with BoxedArray<> in method protected dispatchStringArrayProperty(property String[], param K) : T from class org.neo4j.server.helpers.PropertyTypeDispatcher


    protected T dispatchPointArrayProperty( final Point[] property, K param )
    {
        return dispatchPointArrayProperty( new BoxedArray<>( property )
        {
            @Override
            public Point[] getClonedArray()
            {
                return property.clone();
            }
        }, param );
    }

    protected T dispatchPointArrayProperty( final Point[] property, K param )
    {
        return dispatchPointArrayProperty( new BoxedArray<Point[], Point>( property )
        {
            @Override
            public Point[] getClonedArray()
            {
                return property.clone();
            }
        }, param );
    }

Replace Generic With Diamond BoxedArray<Point[],Point> with BoxedArray<> in method protected dispatchPointArrayProperty(property Point[], param K) : T from class org.neo4j.server.helpers.PropertyTypeDispatcher


    protected T dispatchTemporalArrayProperty( final Temporal[] property, K param )
    {
        return dispatchTemporalArrayProperty( new BoxedArray<>( property )
        {
            @Override
            public Temporal[] getClonedArray()
            {
                return property.clone();
            }
        }, param );
    }

    protected T dispatchTemporalArrayProperty( final Temporal[] property, K param )
    {
        return dispatchTemporalArrayProperty( new BoxedArray<Temporal[], Temporal>( property )
        {
            @Override
            public Temporal[] getClonedArray()
            {
                return property.clone();
            }
        }, param );
    }

Replace Generic With Diamond BoxedArray<Temporal[],Temporal> with BoxedArray<> in method protected dispatchTemporalArrayProperty(property Temporal[], param K) : T from class org.neo4j.server.helpers.PropertyTypeDispatcher


    protected T dispatchTemporalAmountArrayProperty( final TemporalAmount[] property, K param )
    {
        return dispatchTemporalAmountArrayProperty( new BoxedArray<>( property )
        {
            @Override
            public TemporalAmount[] getClonedArray()
            {
                return property.clone();
            }
        }, param );
    }

    protected T dispatchTemporalAmountArrayProperty( final TemporalAmount[] property, K param )
    {
        return dispatchTemporalAmountArrayProperty( new BoxedArray<TemporalAmount[], TemporalAmount>( property )
        {
            @Override
            public TemporalAmount[] getClonedArray()
            {
                return property.clone();
            }
        }, param );
    }

Replace Generic With Diamond BoxedArray<TemporalAmount[],TemporalAmount> with BoxedArray<> in method protected dispatchTemporalAmountArrayProperty(property TemporalAmount[], param K) : T from class org.neo4j.server.helpers.PropertyTypeDispatcher


    private static Iterable<?> map( RecordEvent recordEvent )
    {
        return new IterableWrapper<>( recordEvent.getColumns() )
        {
            @Override
            protected Object underlyingObjectToObject( String key )
            {
                return recordEvent.getValue( key );
            }
        };
    }

    private static Iterable<?> map( RecordEvent recordEvent )
    {
        return new IterableWrapper<Object, String>( recordEvent.getColumns() )
        {
            @Override
            protected Object underlyingObjectToObject( String key )
            {
                return recordEvent.getValue( key );
            }
        };
    }

Replace Generic With Diamond IterableWrapper<Object,String> with IterableWrapper<> in method private map(recordEvent RecordEvent) : Iterable<?> from class org.neo4j.server.http.cypher.format.output.json.GraphExtractionWriter


    @Mapping( "nodes" )
    public ListRepresentation nodes()
    {
        return new ListRepresentation( RepresentationType.NODE,
                                       new IterableWrapper<>( path.nodes() )
                                       {
                                           @Override
                                           protected Representation underlyingObjectToObject( Node node )
                                           {
                                               return ValueRepresentation.uri( NodeRepresentation.path( node ) );
                                           }
                                       } );
    }

    @Mapping( "nodes" )
    public ListRepresentation nodes()
    {
        return new ListRepresentation( RepresentationType.NODE,
                new IterableWrapper<Representation, Node>( path.nodes() )
                {
                    @Override
                    protected Representation underlyingObjectToObject( Node node )
                    {
                        return ValueRepresentation.uri( NodeRepresentation.path( node ) );
                    }
                } );
    }

Replace Generic With Diamond ListRepresentation with ListRepresentation in method public nodes() : ListRepresentation from class org.neo4j.server.rest.repr.PathRepresentation


    @Mapping( "relationships" )
    public ListRepresentation relationships()
    {
        return new ListRepresentation( RepresentationType.RELATIONSHIP,
                                       new IterableWrapper<>( path.relationships() )
                                       {
                                           @Override
                                           protected Representation underlyingObjectToObject( Relationship node )
                                           {
                                               return ValueRepresentation.uri( RelationshipRepresentation.path( node ) );
                                           }
                                       } );
    }

    @Mapping( "relationships" )
    public ListRepresentation relationships()
    {
        return new ListRepresentation( RepresentationType.RELATIONSHIP,
                new IterableWrapper<Representation, Relationship>( path.relationships() )
                {
                    @Override
                    protected Representation underlyingObjectToObject( Relationship node )
                    {
                        return ValueRepresentation.uri( RelationshipRepresentation.path( node ) );
                    }
                } );
    }

Replace Generic With Diamond ListRepresentation with ListRepresentation in method public relationships() : ListRepresentation from class org.neo4j.server.rest.repr.PathRepresentation


    @Mapping( "directions" )
    public ListRepresentation directions()
    {
        ArrayList<String> directionStrings = new ArrayList<>();

        Iterator<Node> nodeIterator = path.nodes().iterator();
        Iterator<Relationship> relationshipIterator = path.relationships().iterator();

        Relationship rel;
        Node startNode;
        Node endNode = nodeIterator.next();

        while ( relationshipIterator.hasNext() )
        {
            rel = relationshipIterator.next();
            startNode = endNode;
            endNode = nodeIterator.next();
            if ( rel.getStartNode().equals(startNode) && rel.getEndNode().equals(endNode) )
            {
                directionStrings.add( "->" );
            }
            else
            {
                directionStrings.add( "<-" );
            }
        }

        return new ListRepresentation( RepresentationType.STRING,
                                       new IterableWrapper<>( directionStrings )
                                       {
                                           @Override
                                           protected Representation underlyingObjectToObject( String directionString )
                                           {
                                               return ValueRepresentation.string( directionString );
                                           }
                                       } );
    }

    @Mapping( "directions" )
    public ListRepresentation directions()
    {
        ArrayList<String> directionStrings = new ArrayList<>();

        Iterator<Node> nodeIterator = path.nodes().iterator();
        Iterator<Relationship> relationshipIterator = path.relationships().iterator();

        Relationship rel;
        Node startNode;
        Node endNode = nodeIterator.next();

        while ( relationshipIterator.hasNext() )
        {
            rel = relationshipIterator.next();
            startNode = endNode;
            endNode = nodeIterator.next();
            if ( rel.getStartNode().equals(startNode) && rel.getEndNode().equals(endNode) )
            {
                directionStrings.add( "->" );
            }
            else
            {
                directionStrings.add( "<-" );
            }
        }

        return new ListRepresentation( RepresentationType.STRING,
                new IterableWrapper<Representation, String>( directionStrings )
                {
                    @Override
                    protected Representation underlyingObjectToObject( String directionString )
                    {
                        return ValueRepresentation.string(directionString);
                    }
                } );
    }

Replace Generic With Diamond ListRepresentation with ListRepresentation in method public directions() : ListRepresentation from class org.neo4j.server.rest.repr.PathRepresentation


    /**
     * Utility to wrap a singleton value as an injectable.
     *
     * @param type the type that JAX-RS classes should ask for
     * @param obj the value
     * @param <T> same as type
     * @return
     */
    static <T> Injectable<T> injectable( Class<T> type, T obj )
    {
        return new Injectable<>()
        {
            @Override
            public T getValue()
            {
                return obj;
            }

            @Override
            public Class<T> getType()
            {
                return type;
            }
        };
    }

    /**
     * Utility to wrap a singleton value as an injectable.
     *
     * @param type the type that JAX-RS classes should ask for
     * @param obj the value
     * @param <T> same as type
     * @return
     */
    static <T> Injectable<T> injectable( Class<T> type, T obj )
    {
        return new Injectable<T>()
        {
            @Override
            public T getValue()
            {
                return obj;
            }

            @Override
            public Class<T> getType()
            {
                return type;
            }
        };
    }

Replace Generic With Diamond Injectable<T> with Injectable<> in method public injectable(type Class<T>, obj T) : Injectable<T> from class org.neo4j.server.web.Injectable


    /**
     * Checks that exception has expected array or suppressed exceptions.
     *
     * @param expectedSuppressedErrors expected suppressed exceptions.
     * @return new matcher.
     */
    public static Matcher<Throwable> hasSuppressed( Throwable... expectedSuppressedErrors )
    {
        return new TypeSafeMatcher<>()
        {
            @Override
            protected boolean matchesSafely( Throwable item )
            {
                return Arrays.equals( item.getSuppressed(), expectedSuppressedErrors );
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendText( "a throwable with suppressed:\n" );

                if ( expectedSuppressedErrors.length == 0 )
                {
                    description.appendText( "a throwable without suppressed" );
                }
                else
                {
                    description.appendText( "a throwable with suppressed:\n" );

                    String expectedSuppressedAsString = Arrays.stream( expectedSuppressedErrors )
                                                              .map( ExceptionUtils::readStackTrace )
                                                              .collect( joining( "\n", "[\n", "]" ) );

                    description.appendText( expectedSuppressedAsString );
                }
            }
        };
    }

    /**
     * Checks that exception has expected array or suppressed exceptions.
     *
     * @param expectedSuppressedErrors expected suppressed exceptions.
     * @return new matcher.
     */
    public static Matcher<Throwable> hasSuppressed( Throwable... expectedSuppressedErrors )
    {
        return new TypeSafeMatcher<Throwable>()
        {
            @Override
            protected boolean matchesSafely( Throwable item )
            {
                return Arrays.equals( item.getSuppressed(), expectedSuppressedErrors );
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendText( "a throwable with suppressed:\n" );

                if ( expectedSuppressedErrors.length == 0 )
                {
                    description.appendText( "a throwable without suppressed" );
                }
                else
                {
                    description.appendText( "a throwable with suppressed:\n" );

                    String expectedSuppressedAsString = Arrays.stream( expectedSuppressedErrors )
                            .map( ExceptionUtils::readStackTrace )
                            .collect( joining( "\n", "[\n", "]" ) );

                    description.appendText( expectedSuppressedAsString );
                }
            }
        };
    }

Replace Generic With Diamond TypeSafeMatcher<Throwable> with TypeSafeMatcher<> in method public hasSuppressed(expectedSuppressedErrors Throwable...) : Matcher<Throwable> from class org.neo4j.test.matchers.CommonMatchers