    @Override
    public Object removeProperty( String key )
    {
        KernelTransaction transaction = internalTransaction.kernelTransaction();
        int propertyKeyId;
        try ( Statement ignore = transaction.acquireStatement() )
        {
            propertyKeyId = transaction.tokenWrite().propertyKeyGetOrCreateForName( key );
        }
        catch ( IllegalTokenNameException e )
        {
            throw new IllegalArgumentException( format( "Invalid property key '%s'.", key ), e );
        }
        catch ( KernelException e )
        {
            throw new TransactionFailureException( "Unknown error trying to get property key token", e );
        }

        try
        {
            return transaction.dataWrite().relationshipRemoveProperty( id, propertyKeyId ).asObjectCopy();
        }
        catch ( InvalidTransactionTypeKernelException e )
        {
            throw new ConstraintViolationException( e.getMessage(), e );
        }
        catch ( EntityNotFoundException e )
        {
            throw new NotFoundException( e );
        }
    }

    @Override
    public Object removeProperty( String key )
    {
        KernelTransaction transaction = internalTransaction.kernelTransaction();
        int propertyKeyId;
        try
        {
            propertyKeyId = transaction.tokenWrite().propertyKeyGetOrCreateForName( key );
        }
        catch ( IllegalTokenNameException e )
        {
            throw new IllegalArgumentException( format( "Invalid property key '%s'.", key ), e );
        }
        catch ( KernelException e )
        {
            throw new TransactionFailureException( "Unknown error trying to get property key token", e );
        }

        try
        {
            return transaction.dataWrite().relationshipRemoveProperty( id, propertyKeyId ).asObjectCopy();
        }
        catch ( InvalidTransactionTypeKernelException e )
        {
            throw new ConstraintViolationException( e.getMessage(), e );
        }
        catch ( EntityNotFoundException e )
        {
            throw new NotFoundException( e );
        }
    }

Try With Resources try(Statement ignore=transaction.acquireStatement()) in method public removeProperty(key String) : Object from class org.neo4j.kernel.impl.core.RelationshipEntity


        @Override
        public IndexDefinition createIndexDefinition(
                Label[] labels, String indexName, IndexType indexType, IndexConfig indexConfig, String... propertyKeys )
        {
            try ( Statement ignore = transaction.acquireStatement() )
            {
                TokenWrite tokenWrite = transaction.tokenWrite();
                String[] labelNames = Arrays.stream( labels ).map( Label::name ).toArray( String[]::new );
                int[] labelIds = new int[labels.length];
                tokenWrite.labelGetOrCreateForNames( labelNames, labelIds );
                int[] propertyKeyIds = getOrCreatePropertyKeyIds( tokenWrite, propertyKeys );
                SchemaDescriptor schema;
                if ( indexType == IndexType.FULLTEXT )
                {
                    schema = fulltext( EntityType.NODE, labelIds, propertyKeyIds );
                }
                else if ( labelIds.length == 1 )
                {
                    schema = forLabel( labelIds[0], propertyKeyIds );
                }
                else
                {
                    throw new IllegalArgumentException( indexType + " indexes can only be created with exactly one label, " +
                            "but got " + ( labelIds.length == 0 ? "no" : String.valueOf( labelIds.length ) ) + " labels." );
                }
                IndexDescriptor indexReference = createIndex( indexName, schema, indexType, indexConfig );
                return new IndexDefinitionImpl( this, indexReference, labels, propertyKeys, false );
            }
            catch ( IllegalTokenNameException e )
            {
                throw new IllegalArgumentException( e );
            }
            catch ( InvalidTransactionTypeKernelException | SchemaKernelException e )
            {
                throw new ConstraintViolationException(
                        e.getUserMessage( new SilentTokenNameLookup( transaction.tokenRead() ) ), e );
            }
            catch ( KernelException e )
            {
                throw new TransactionFailureException( "Unknown error trying to create token ids", e );
            }
        }

        @Override
        public IndexDefinition createIndexDefinition(
                Label[] labels, String indexName, IndexType indexType, IndexConfig indexConfig, String... propertyKeys )
        {
            try
            {
                TokenWrite tokenWrite = transaction.tokenWrite();
                String[] labelNames = Arrays.stream( labels ).map( Label::name ).toArray( String[]::new );
                int[] labelIds = new int[labels.length];
                tokenWrite.labelGetOrCreateForNames( labelNames, labelIds );
                int[] propertyKeyIds = getOrCreatePropertyKeyIds( tokenWrite, propertyKeys );
                SchemaDescriptor schema;
                if ( indexType == IndexType.FULLTEXT )
                {
                    schema = fulltext( EntityType.NODE, labelIds, propertyKeyIds );
                }
                else if ( labelIds.length == 1 )
                {
                    schema = forLabel( labelIds[0], propertyKeyIds );
                }
                else
                {
                    throw new IllegalArgumentException( indexType + " indexes can only be created with exactly one label, " +
                            "but got " + ( labelIds.length == 0 ? "no" : String.valueOf( labelIds.length ) ) + " labels." );
                }
                IndexDescriptor indexReference = createIndex( indexName, schema, indexType, indexConfig );
                return new IndexDefinitionImpl( this, indexReference, labels, propertyKeys, false );
            }
            catch ( IllegalTokenNameException e )
            {
                throw new IllegalArgumentException( e );
            }
            catch ( InvalidTransactionTypeKernelException | SchemaKernelException e )
            {
                throw new ConstraintViolationException(
                        e.getUserMessage( new SilentTokenNameLookup( transaction.tokenRead() ) ), e );
            }
            catch ( KernelException e )
            {
                throw new TransactionFailureException( "Unknown error trying to create token ids", e );
            }
        }

Try With Resources try(Statement ignore=transaction.acquireStatement()) in method public createIndexDefinition(labels Label[], indexName String, indexType IndexType, indexConfig IndexConfig, propertyKeys String...) : IndexDefinition from class org.neo4j.kernel.impl.coreapi.schema.SchemaImpl.GDBSchemaActions


        @Override
        public IndexDefinition createIndexDefinition( RelationshipType[] types, String indexName, IndexType indexType, IndexConfig indexConfig,
                String... propertyKeys )
        {
            try ( Statement ignore = transaction.acquireStatement() )
            {
                TokenWrite tokenWrite = transaction.tokenWrite();
                String[] typeNames = Arrays.stream( types ).map( RelationshipType::name ).toArray( String[]::new );
                int[] typeIds = new int[types.length];
                tokenWrite.relationshipTypeGetOrCreateForNames( typeNames, typeIds );
                int[] propertyKeyIds = getOrCreatePropertyKeyIds( tokenWrite, propertyKeys );
                SchemaDescriptor schema;
                if ( indexType == IndexType.FULLTEXT )
                {
                    schema = fulltext( EntityType.RELATIONSHIP, typeIds, propertyKeyIds );
                }
                else
                {
                    throw new IllegalArgumentException( indexType + " indexes cannot be created on relationship types." );
                }
                IndexDescriptor indexReference = createIndex( indexName, schema, indexType, indexConfig );
                return new IndexDefinitionImpl( this, indexReference, types, propertyKeys, false );
            }
            catch ( IllegalTokenNameException e )
            {
                throw new IllegalArgumentException( e );
            }
            catch ( InvalidTransactionTypeKernelException | SchemaKernelException e )
            {
                throw new ConstraintViolationException(
                        e.getUserMessage( new SilentTokenNameLookup( transaction.tokenRead() ) ), e );
            }
            catch ( KernelException e )
            {
                throw new TransactionFailureException( "Unknown error trying to create token ids", e );
            }
        }

        @Override
        public IndexDefinition createIndexDefinition( RelationshipType[] types, String indexName, IndexType indexType, IndexConfig indexConfig,
                String... propertyKeys )
        {
            try
            {
                TokenWrite tokenWrite = transaction.tokenWrite();
                String[] typeNames = Arrays.stream( types ).map( RelationshipType::name ).toArray( String[]::new );
                int[] typeIds = new int[types.length];
                tokenWrite.relationshipTypeGetOrCreateForNames( typeNames, typeIds );
                int[] propertyKeyIds = getOrCreatePropertyKeyIds( tokenWrite, propertyKeys );
                SchemaDescriptor schema;
                if ( indexType == IndexType.FULLTEXT )
                {
                    schema = fulltext( EntityType.RELATIONSHIP, typeIds, propertyKeyIds );
                }
                else
                {
                    throw new IllegalArgumentException( indexType + " indexes cannot be created on relationship types." );
                }
                IndexDescriptor indexReference = createIndex( indexName, schema, indexType, indexConfig );
                return new IndexDefinitionImpl( this, indexReference, types, propertyKeys, false );
            }
            catch ( IllegalTokenNameException e )
            {
                throw new IllegalArgumentException( e );
            }
            catch ( InvalidTransactionTypeKernelException | SchemaKernelException e )
            {
                throw new ConstraintViolationException(
                        e.getUserMessage( new SilentTokenNameLookup( transaction.tokenRead() ) ), e );
            }
            catch ( KernelException e )
            {
                throw new TransactionFailureException( "Unknown error trying to create token ids", e );
            }
        }

Try With Resources try(Statement ignore=transaction.acquireStatement()) in method public createIndexDefinition(types RelationshipType[], indexName String, indexType IndexType, indexConfig IndexConfig, propertyKeys String...) : IndexDefinition from class org.neo4j.kernel.impl.coreapi.schema.SchemaImpl.GDBSchemaActions


    @Override
    public IndexState getIndexState( final IndexDefinition index )
    {
        try ( Statement ignore = transaction.acquireStatement() )
        {

            SchemaRead schemaRead = transaction.schemaRead();
            IndexDescriptor reference = getIndexReference( schemaRead, transaction.tokenRead(), (IndexDefinitionImpl) index );
            InternalIndexState indexState = schemaRead.indexGetState( reference );
            switch ( indexState )
            {
            case POPULATING:
                return POPULATING;
            case ONLINE:
                return ONLINE;
            case FAILED:
                return FAILED;
            default:
                throw new IllegalArgumentException( String.format( "Illegal index state %s", indexState ) );
            }
        }
        catch ( KernelException e )
        {
            throw newIndexNotFoundException( index, e );
        }
    }

    @Override
    public IndexState getIndexState( final IndexDefinition index )
    {
        try
        {
            SchemaRead schemaRead = transaction.schemaRead();
            IndexDescriptor reference = getIndexReference( schemaRead, transaction.tokenRead(), (IndexDefinitionImpl) index );
            InternalIndexState indexState = schemaRead.indexGetState( reference );
            switch ( indexState )
            {
            case POPULATING:
                return POPULATING;
            case ONLINE:
                return ONLINE;
            case FAILED:
                return FAILED;
            default:
                throw new IllegalArgumentException( String.format( "Illegal index state %s", indexState ) );
            }
        }
        catch ( KernelException e )
        {
            throw newIndexNotFoundException( index, e );
        }
    }

Try With Resources try(Statement ignore=transaction.acquireStatement()) in method public getIndexState(index IndexDefinition) : IndexState from class org.neo4j.kernel.impl.coreapi.schema.SchemaImpl


    @Override
    public IndexPopulationProgress getIndexPopulationProgress( IndexDefinition index )
    {
        try ( Statement ignore = transaction.acquireStatement() )
        {
            SchemaRead schemaRead = transaction.schemaRead();
            IndexDescriptor descriptor = getIndexReference( schemaRead, transaction.tokenRead(), (IndexDefinitionImpl) index );
            PopulationProgress progress = schemaRead.indexGetPopulationProgress( descriptor );
            return progress.toIndexPopulationProgress();
        }
        catch ( KernelException e )
        {
            throw newIndexNotFoundException( index, e );
        }
    }

    @Override
    public IndexPopulationProgress getIndexPopulationProgress( IndexDefinition index )
    {
        try
        {
            SchemaRead schemaRead = transaction.schemaRead();
            IndexDescriptor descriptor = getIndexReference( schemaRead, transaction.tokenRead(), (IndexDefinitionImpl) index );
            PopulationProgress progress = schemaRead.indexGetPopulationProgress( descriptor );
            return progress.toIndexPopulationProgress();
        }
        catch ( KernelException e )
        {
            throw newIndexNotFoundException( index, e );
        }
    }

Try With Resources try(Statement ignore=transaction.acquireStatement()) in method public getIndexPopulationProgress(index IndexDefinition) : IndexPopulationProgress from class org.neo4j.kernel.impl.coreapi.schema.SchemaImpl


    @Override
    public String getIndexFailure( IndexDefinition index )
    {
        try ( Statement ignore = transaction.acquireStatement() )
        {
            SchemaRead schemaRead = transaction.schemaRead();
            IndexDescriptor descriptor = getIndexReference( schemaRead, transaction.tokenRead(), (IndexDefinitionImpl) index );
            return schemaRead.indexGetFailure( descriptor );
        }
        catch ( KernelException e )
        {
            throw newIndexNotFoundException( index, e );
        }
    }

    @Override
    public String getIndexFailure( IndexDefinition index )
    {
        try
        {
            SchemaRead schemaRead = transaction.schemaRead();
            IndexDescriptor descriptor = getIndexReference( schemaRead, transaction.tokenRead(), (IndexDefinitionImpl) index );
            return schemaRead.indexGetFailure( descriptor );
        }
        catch ( KernelException e )
        {
            throw newIndexNotFoundException( index, e );
        }
    }

Try With Resources try(Statement ignore=transaction.acquireStatement()) in method public getIndexFailure(index IndexDefinition) : String from class org.neo4j.kernel.impl.coreapi.schema.SchemaImpl


    void writeRecord( RecordEvent recordEvent )
    {
        try
        {
            out.writeStartObject();

            try ( TransactionStateChecker txStateChecker = TransactionStateChecker.create( transactionHandle.getContext() ) )
            {
                writer.write( out, recordEvent, txStateChecker );
            }
            finally
            {
                out.writeEndObject();
            }
            flush();
        }
        catch ( JsonGenerationException e )
        {
            throw new IllegalStateException( e );
        }
        catch ( IOException e )
        {
            throw new ConnectionException( "Failed to write to the connection", e );
        }
    }

    void writeRecord( RecordEvent recordEvent )
    {
        try
        {
            out.writeStartObject();

            TransactionStateChecker txStateChecker = TransactionStateChecker.create( transactionHandle.getContext() );
            try
            {
                writer.write( out, recordEvent, txStateChecker );
            }
            finally
            {
                out.writeEndObject();
            }
            flush();
        }
        catch ( JsonGenerationException e )
        {
            throw new IllegalStateException( e );
        }
        catch ( IOException e )
        {
            throw new ConnectionException( "Failed to write to the connection", e );
        }
    }

Try With Resources try(TransactionStateChecker txStateChecker=TransactionStateChecker.create(transactionHandle.getContext())) in method package writeRecord(recordEvent RecordEvent) : void from class org.neo4j.server.http.cypher.format.output.json.ExecutionResultSerializer


        @Override
        public IndexDefinition createIndexDefinition(
                Label[] labels, String indexName, IndexType indexType, IndexConfig indexConfig, String... propertyKeys )
        {
            try ( Statement ignore = transaction.acquireStatement() )
            {
                try
                {
                    TokenWrite tokenWrite = transaction.tokenWrite();
                    String[] labelNames = Arrays.stream( labels ).map( Label::name ).toArray( String[]::new );
                    int[] labelIds = new int[labels.length];
                    tokenWrite.labelGetOrCreateForNames( labelNames, labelIds );
                    int[] propertyKeyIds = getOrCreatePropertyKeyIds( tokenWrite, propertyKeys );
                    SchemaDescriptor schema;
                    if ( indexType == IndexType.FULLTEXT )
                    {
                        schema = fulltext( EntityType.NODE, labelIds, propertyKeyIds );
                    }
                    else if ( labelIds.length == 1 )
                    {
                        schema = forLabel( labelIds[0], propertyKeyIds );
                    }
                    else
                    {
                        throw new IllegalArgumentException( indexType + " indexes can only be created with exactly one label, " +
                                "but got " + ( labelIds.length == 0 ? "no" : String.valueOf( labelIds.length ) ) + " labels." );
                    }
                    IndexPrototype prototype = IndexPrototype.forSchema( schema );
                    prototype = prototype.withName( indexName );
                    prototype = prototype.withIndexType( fromPublicApi( indexType ) );
                    prototype = prototype.withIndexConfig( indexConfig );
                    IndexDescriptor indexReference = transaction.schemaWrite().indexCreate( prototype );
                    return new IndexDefinitionImpl( this, indexReference, labels, propertyKeys, false );
                }
                catch ( IllegalTokenNameException e )
                {
                    throw new IllegalArgumentException( e );
                }
                catch ( InvalidTransactionTypeKernelException | SchemaKernelException e )
                {
                    throw new ConstraintViolationException(
                            e.getUserMessage( new SilentTokenNameLookup( transaction.tokenRead() ) ), e );
                }
                catch ( KernelException e )
                {
                    throw new TransactionFailureException( "Unknown error trying to create token ids", e );
                }
            }
        }


    @Test
    void openClosePartitionedIndex() throws IOException
    {
        File indexRootFolder = new File( testDir.directory( "reopenIndexFolder" ), "reopenIndex" );
        LuceneSchemaIndexBuilder luceneSchemaIndexBuilder =
                LuceneSchemaIndexBuilder.create( descriptor, config ).withFileSystem( fileSystem ).withIndexRootFolder( indexRootFolder );
        try ( SchemaIndex reopenIndex = luceneSchemaIndexBuilder.build() )
        {
            reopenIndex.open();

            addDocumentToIndex( reopenIndex, 1 );

            reopenIndex.close();
            assertFalse( reopenIndex.isOpen() );

            reopenIndex.open();
            assertTrue( reopenIndex.isOpen() );

            addDocumentToIndex( reopenIndex, 10 );

            reopenIndex.close();
            assertFalse( reopenIndex.isOpen() );

            reopenIndex.open();
            assertTrue( reopenIndex.isOpen() );

            reopenIndex.close();
            reopenIndex.open();
            addDocumentToIndex( reopenIndex, 100 );

            reopenIndex.maybeRefreshBlocking();

            try ( LuceneAllDocumentsReader allDocumentsReader = reopenIndex.allDocumentsReader() )
            {
                assertEquals( 111, allDocumentsReader.maxCount(), "All documents should be visible" );
            }
        }
    }

    @Test
    void openClosePartitionedIndex() throws IOException
    {
        SchemaIndex reopenIndex = null;
        try
        {
            reopenIndex = LuceneSchemaIndexBuilder.create( descriptor, config )
                    .withFileSystem( fileSystem )
                    .withIndexRootFolder( new File( testDir.directory( "reopenIndexFolder" ), "reopenIndex" ) )
                    .build();
            reopenIndex.open();

            addDocumentToIndex( reopenIndex, 1 );

            reopenIndex.close();
            assertFalse( reopenIndex.isOpen() );

            reopenIndex.open();
            assertTrue( reopenIndex.isOpen() );

            addDocumentToIndex( reopenIndex, 10 );

            reopenIndex.close();
            assertFalse( reopenIndex.isOpen() );

            reopenIndex.open();
            assertTrue( reopenIndex.isOpen() );

            reopenIndex.close();
            reopenIndex.open();
            addDocumentToIndex( reopenIndex, 100 );

            reopenIndex.maybeRefreshBlocking();

            try ( LuceneAllDocumentsReader allDocumentsReader = reopenIndex.allDocumentsReader() )
            {
                assertEquals( 111, allDocumentsReader.maxCount(), "All documents should be visible" );
            }
        }
        finally
        {
            if ( reopenIndex != null )
            {
                reopenIndex.close();
            }
        }
    }

Try With Resources try(SchemaIndex reopenIndex=luceneSchemaIndexBuilder.build()) in method package openClosePartitionedIndex() : void from class org.neo4j.kernel.api.impl.schema.LuceneSchemaIndexIT


    /**
     * Extracts txId from first commit entry, when starting reading at the given {@code position}.
     * If no commit entry found in the version, the reader will continue into next version(s) up till
     * {@code maxLogVersion} until finding one.
     *
     * @param initialPosition {@link LogPosition} to start scan from.
     * @param maxLogVersion max log version to scan.
     * @return value object that contains first transaction id of closes commit entry to {@code initialPosition},
     * or {@link LogTailInformation#NO_TRANSACTION_ID} if not found. And failure flag that will be set to true if
     * there was some exception during transaction log processing.
     * @throws IOException on channel close I/O error.
     */
    protected ExtractedTransactionRecord extractFirstTxIdAfterPosition( LogPosition initialPosition, long maxLogVersion ) throws IOException
    {
        long initialVersion = initialPosition.getLogVersion();
        long logVersion = initialVersion;
        while ( logVersion <= maxLogVersion )
        {
            if ( logFiles.versionExists( logVersion ) )
            {
                LogPosition currentPosition = logVersion != initialVersion ? logFiles.extractHeader( logVersion ).getStartPosition() : initialPosition;
                try ( LogVersionedStoreChannel storeChannel = logFiles.openForVersion( logVersion ) )
                {
                    storeChannel.position( currentPosition.getByteOffset() );
                    try ( ReadAheadLogChannel logChannel = new ReadAheadLogChannel( storeChannel );
                            LogEntryCursor cursor = new LogEntryCursor( logEntryReader, logChannel ) )
                    {
                        while ( cursor.next() )
                        {
                            LogEntry entry = cursor.get();
                            if ( entry instanceof LogEntryCommit )
                            {
                                return new ExtractedTransactionRecord( ((LogEntryCommit) entry).getTxId() );
                            }
                        }
                    }
                }
                catch ( Throwable t )
                {
                    monitor.corruptedLogFile( currentPosition.getLogVersion(), t );
                    return new ExtractedTransactionRecord( true );
                }
                logVersion = currentPosition.getLogVersion() + 1;
            }
            else
            {
                logVersion += 1;
            }
        }
        return new ExtractedTransactionRecord();
    }

    /**
     * Extracts txId from first commit entry, when starting reading at the given {@code position}.
     * If no commit entry found in the version, the reader will continue into next version(s) up till
     * {@code maxLogVersion} until finding one.
     *
     * @param initialPosition {@link LogPosition} to start scan from.
     * @param maxLogVersion max log version to scan.
     * @return value object that contains first transaction id of closes commit entry to {@code initialPosition},
     * or {@link LogTailInformation#NO_TRANSACTION_ID} if not found. And failure flag that will be set to true if
     * there was some exception during transaction log processing.
     * @throws IOException on channel close I/O error.
     */
    protected ExtractedTransactionRecord extractFirstTxIdAfterPosition( LogPosition initialPosition, long maxLogVersion ) throws IOException
    {
        LogPosition currentPosition = initialPosition;
        while ( currentPosition.getLogVersion() <= maxLogVersion )
        {
            LogVersionedStoreChannel storeChannel = tryOpenStoreChannel( currentPosition );
            if ( storeChannel != null )
            {
                try
                {
                    storeChannel.position( currentPosition.getByteOffset() );
                    try ( ReadAheadLogChannel logChannel = new ReadAheadLogChannel( storeChannel );
                            LogEntryCursor cursor = new LogEntryCursor( logEntryReader, logChannel ) )
                    {
                        while ( cursor.next() )
                        {
                            LogEntry entry = cursor.get();
                            if ( entry instanceof LogEntryCommit )
                            {
                                return new ExtractedTransactionRecord( ((LogEntryCommit) entry).getTxId() );
                            }
                        }
                    }
                }
                catch ( Throwable t )
                {
                    monitor.corruptedLogFile( currentPosition.getLogVersion(), t );
                    return new ExtractedTransactionRecord( true );
                }
                finally
                {
                    storeChannel.close();
                }
            }

            currentPosition = LogPosition.start( currentPosition.getLogVersion() + 1 );
        }
        return new ExtractedTransactionRecord();
    }

Try With Resources try(LogVersionedStoreChannel storeChannel=logFiles.openForVersion(logVersion)) in method protected extractFirstTxIdAfterPosition(initialPosition LogPosition, maxLogVersion long) : ExtractedTransactionRecord from class org.neo4j.kernel.recovery.LogTailScanner


    /**
     * Stores the data in {@code config} into {@code file} in a standard java
     * {@link Properties} format.
     * @param config the data to store in the properties file.
     * @param file the file to store the properties in.
     * @throws IOException IO error.
     */
    public static void store( Map<String, String> config, File file ) throws IOException
    {
        try ( OutputStream stream = new BufferedOutputStream( new FileOutputStream( file ) ) )
        {
            store( config, stream );
        }
    }

    /**
     * Stores the data in {@code config} into {@code file} in a standard java
     * {@link Properties} format.
     * @param config the data to store in the properties file.
     * @param file the file to store the properties in.
     * @throws IOException IO error.
     */
    public static void store( Map<String, String> config, File file ) throws IOException
    {
        OutputStream stream = null;
        try
        {
            stream = new BufferedOutputStream( new FileOutputStream( file ) );
            store( config, stream );
        }
        finally
        {
            closeIfNotNull( stream );
        }
    }

Try With Resources try(OutputStream stream=new BufferedOutputStream(new FileOutputStream(file))) in method public store(config Map<String,String>, file File) : void from class org.neo4j.internal.helpers.collection.MapUtil


    private <T extends RequestMessage> T unpack( RecordingByteChannel channel ) throws Exception
    {
        List<RequestMessage> messages = new ArrayList<>();
        BoltStateMachine stateMachine = mock( BoltStateMachine.class );
        doAnswer( (Answer<Void>) invocationOnMock ->
        {
            RequestMessage msg = invocationOnMock.getArgument( 0 );
            messages.add( msg );
            return null;
        } ).when( stateMachine ).process( any(), any() );
        BoltRequestMessageReader reader = new BoltRequestMessageReaderV3( new SynchronousBoltConnection( stateMachine ),
                mock( BoltResponseMessageWriter.class ), NullLogService.getInstance() );

        byte[] bytes = channel.getBytes();
        String serialized = HexPrinter.hex( bytes );
        Neo4jPack.Unpacker unpacker = neo4jPack.newUnpacker( new PackedInputArray( bytes ) );
        try
        {
            reader.read( unpacker );
        }
        catch ( Throwable e )
        {
            throw new AssertionError( "Failed to unpack message, wire data was:\n" + serialized + "[" + bytes.length + "b]", e );
        }

        return (T) messages.get( 0 );
    }

    private <T extends RequestMessage> T unpack( RecordingByteChannel channel ) throws Exception
    {
        List<RequestMessage> messages = new ArrayList<>();
        BoltStateMachine stateMachine = mock( BoltStateMachine.class );
        doAnswer( new Answer<Void>()
        {
            @Override
            public Void answer( InvocationOnMock invocationOnMock ) throws Throwable
            {
                RequestMessage msg = invocationOnMock.getArgument( 0 );
                messages.add( msg );
                return null;
            }
        } ).when( stateMachine ).process( any(), any() );
        BoltRequestMessageReader reader = new BoltRequestMessageReaderV3( new SynchronousBoltConnection( stateMachine ),
                mock( BoltResponseMessageWriter.class ), NullLogService.getInstance() );

        byte[] bytes = channel.getBytes();
        String serialized = HexPrinter.hex( bytes );
        Neo4jPack.Unpacker unpacker = neo4jPack.newUnpacker( new PackedInputArray( bytes ) );
        try
        {
            reader.read( unpacker );
        }
        catch ( Throwable e )
        {
            throw new AssertionError( "Failed to unpack message, wire data was:\n" + serialized + "[" + bytes.length + "b]", e );
        }

        return (T) messages.get( 0 );
    }

Replace Anonymous With Lambda org.neo4j.bolt.v3.messaging.BoltRequestMessageV3Test.unpack.process.when.doAnswer.new Answer<Void> with invocationOnMock -> {RequestMessage msg=invocationOnMock.getArgument(0); in method private unpack(channel RecordingByteChannel) : T from class org.neo4j.bolt.v3.messaging.BoltRequestMessageV3Test


    private Neo4jMatchers.Deferred<Label> labels( final Node myNode )
    {
        return new Neo4jMatchers.Deferred<>()
        {
            @Override
            protected Iterable<Label> manifest()
            {
                return myNode.getLabels();
            }
        };
    }

    private Neo4jMatchers.Deferred<Label> labels( final Node myNode )
    {
        return new Neo4jMatchers.Deferred<Label>( dbRule.getGraphDatabaseAPI() )
        {
            @Override
            protected Iterable<Label> manifest()
            {
                return myNode.getLabels();
            }
        };
    }

Replace Generic With Diamond Neo4jMatchers.Deferred<Label> with Neo4jMatchers.Deferred<> in method private labels(myNode Node) : Neo4jMatchers.Deferred<Label> from class org.neo4j.graphdb.IndexingAcceptanceTest


    private static <KEY,VALUE> void assertReportException( GBPTree<KEY,VALUE> index ) throws IOException
    {
        MutableBoolean called = new MutableBoolean();
        index.consistencyCheck( new GBPTreeConsistencyCheckVisitor.Adaptor<>()
        {
            @Override
            public void exception( Exception e )
            {
                called.setTrue();
            }
        } );
        assertCalled( called );
    }

    private static <KEY,VALUE> void assertReportException( GBPTree<KEY,VALUE> index ) throws IOException
    {
        MutableBoolean called = new MutableBoolean();
        index.consistencyCheck( new GBPTreeConsistencyCheckVisitor.Adaptor<KEY>()
        {
            @Override
            public void exception( Exception e )
            {
                called.setTrue();
            }
        } );
        assertCalled( called );
    }

Replace Generic With Diamond GBPTreeConsistencyCheckVisitor.Adaptor<KEY> with GBPTreeConsistencyCheckVisitor.Adaptor<> in method private assertReportException(index GBPTree<KEY,VALUE>) : void from class org.neo4j.index.internal.gbptree.GBPTreeConsistencyCheckerTestBase


    private Iterable<String> asStrings( Iterable<RelationshipType> relationshipTypes )
    {
        return new IterableWrapper<>( relationshipTypes )
        {
            @Override
            protected String underlyingObjectToObject( RelationshipType object )
            {
                return object.name();
            }
        };
    }

    private Iterable<String> asStrings( Iterable<RelationshipType> relationshipTypes )
    {
        return new IterableWrapper<String, RelationshipType>( relationshipTypes )
        {
            @Override
            protected String underlyingObjectToObject( RelationshipType object )
            {
                return object.name();
            }
        };
    }

Replace Generic With Diamond IterableWrapper<String,RelationshipType> with IterableWrapper<> in method private asStrings(relationshipTypes Iterable<RelationshipType>) : Iterable<String> from class org.neo4j.kernel.impl.core.TestRelationshipCount


    private static <T extends Entity> Function<Transaction, Void> propertyWrite(
            Class<T> type, final T entity, final String key, final Object value )
    {
        return new FailureRewrite<>( type.getSimpleName() + ".setProperty()" )
        {
            @Override
            Void perform( Transaction transaction )
            {
                entity.setProperty( key, value );
                return null;
            }
        };
    }

    private static <T extends PropertyContainer> Function<Transaction, Void> propertyWrite(
            Class<T> type, final T entity, final String key, final Object value )
    {
        return new FailureRewrite<Void>( type.getSimpleName() + ".setProperty()" )
        {
            @Override
            Void perform( Transaction transaction )
            {
                entity.setProperty( key, value );
                return null;
            }
        };
    }

Replace Generic With Diamond FailureRewrite<Void> with FailureRewrite<> in method private propertyWrite(type Class<T>, entity T, key String, value Object) : Function<Transaction,Void> from class org.neo4j.kernel.impl.api.DataAndSchemaTransactionSeparationIT


    private void doImport( Input input, Collector badCollector )
    {
        boolean success = false;

        File internalLogFile = databaseConfig.get( store_internal_log_path ).toFile();
        try ( JobScheduler jobScheduler = createInitialisedScheduler();
                OutputStream outputStream = FileSystemUtils.createOrOpenAsOutputStream( fileSystem, internalLogFile, true ) )
        {
            LogProvider logProvider = Util.configuredLogProvider( databaseConfig, outputStream );

            ExecutionMonitor executionMonitor = verbose ? new SpectrumExecutionMonitor( 2, TimeUnit.SECONDS, stdOut,
                    SpectrumExecutionMonitor.DEFAULT_WIDTH ) : ExecutionMonitors.defaultVisible();

            BatchImporter importer = BatchImporterFactory.withHighestPriority().instantiate( databaseLayout,
                    fileSystem,
                    null, // no external page cache
                    importConfig,
                    new SimpleLogService( NullLogProvider.getInstance(), logProvider ),
                    executionMonitor,
                    EMPTY,
                    databaseConfig,
                    RecordFormatSelector.selectForConfig( databaseConfig, logProvider ),
                    new PrintingImportLogicMonitor( stdOut, stdErr ),
                    jobScheduler, badCollector, TransactionLogsInitializer.INSTANCE );

            printOverview( databaseLayout.databaseDirectory(), nodeFiles, relationshipFiles, importConfig, stdOut );

            importer.doImport( input );

            success = true;
        }
        catch ( Exception e )
        {
            throw andPrintError( "Import error", e, verbose, stdErr );
        }
        finally
        {
            long numberOfBadEntries = badCollector.badEntries();

            if ( reportFile != null )
            {
                if ( numberOfBadEntries > 0 )
                {
                    stdOut.println( "There were bad entries which were skipped and logged into " + reportFile.getAbsolutePath() );
                }
            }

            if ( !success )
            {
                stdErr.println( "WARNING Import failed. The store files in " + databaseLayout.databaseDirectory().getAbsolutePath() +
                        " are left as they are, although they are likely in an unusable state. " +
                        "Starting a database on these store files will likely fail or observe inconsistent records so " +
                        "start at your own risk or delete the store manually" );
            }
        }
    }

    private void doImport( Input input, Collector badCollector ) throws IOException
    {
        boolean success;
        LifeSupport life = new LifeSupport();

        File internalLogFile = databaseConfig.get( store_internal_log_path ).toFile();
        OutputStream outputStream = FileSystemUtils.createOrOpenAsOutputStream( fileSystem, internalLogFile, true );
        LogProvider logProvider = Util.logProviderRespectingConfig( databaseConfig, outputStream );

        final JobScheduler jobScheduler = life.add( createScheduler() );
        life.add( new LifecycleAdapter()
        {
            @Override
            public void stop() throws Exception
            {
                outputStream.close();
            }
        });

        life.start();
        ExecutionMonitor executionMonitor = verbose ? new SpectrumExecutionMonitor( 2, TimeUnit.SECONDS, stdOut,
            SpectrumExecutionMonitor.DEFAULT_WIDTH ) : ExecutionMonitors.defaultVisible();
        BatchImporter importer = BatchImporterFactory.withHighestPriority().instantiate( databaseLayout,
            fileSystem,
            null, // no external page cache
            importConfig,
            new SimpleLogService( NullLogProvider.getInstance(), logProvider ),
            executionMonitor,
            EMPTY,
            databaseConfig,
            RecordFormatSelector.selectForConfig( databaseConfig, logProvider ),
            new PrintingImportLogicMonitor( stdOut, stdErr ),
            jobScheduler, badCollector, TransactionLogsInitializer.INSTANCE );
        printOverview( databaseLayout.databaseDirectory(), nodeFiles, relationshipFiles, importConfig, stdOut );
        success = false;
        try
        {
            importer.doImport( input );
            success = true;
        }
        catch ( Exception e )
        {
            throw andPrintError( "Import error", e, verbose, stdErr );
        }
        finally
        {
            long numberOfBadEntries = badCollector.badEntries();

            if ( reportFile != null )
            {
                if ( numberOfBadEntries > 0 )
                {
                    stdOut.println( "There were bad entries which were skipped and logged into " + reportFile.getAbsolutePath() );
                }
            }

            life.shutdown();

            if ( !success )
            {
                stdErr.println( "WARNING Import failed. The store files in " + databaseLayout.databaseDirectory().getAbsolutePath() +
                        " are left as they are, although they are likely in an unusable state. " +
                        "Starting a database on these store files will likely fail or observe inconsistent records so " +
                        "start at your own risk or delete the store manually" );
            }
        }
    }

Try With Resources try(JobScheduler jobScheduler=createInitialisedScheduler(); OutputStream outputStream=FileSystemUtils.createOrOpenAsOutputStream(fileSystem,internalLogFile,true)) in method private doImport(input Input, badCollector Collector) : void from class org.neo4j.importer.CsvImporter


    public static String firstLinesOf( String string, int maxNumberOfLines )
    {
        // Totally verbose implementation of this functionality :)
        StringWriter stringWriter = new StringWriter();
        PrintWriter writer = new PrintWriter( stringWriter );
        try
        {
            try ( BufferedReader reader = new BufferedReader( new StringReader( string ) ) )
            {
                String line = null;
                for ( int count = 0; (line = reader.readLine()) != null && count < maxNumberOfLines;
                      count++ )
                {
                    writer.println( line );
                }
            }
            writer.close();
            return stringWriter.getBuffer().toString();
        }
        catch ( IOException e )
        {
            throw new RuntimeException( "Can't happen", e );
        }
    }

    public static String firstLinesOf( String string, int maxNumberOfLines )
    {
        // Totally verbose implementation of this functionality :)
        StringWriter stringWriter = new StringWriter();
        PrintWriter writer = new PrintWriter( stringWriter );
        try
        {
            BufferedReader reader = new BufferedReader( new StringReader( string ) );
            String line = null;
            for ( int count = 0; ( line = reader.readLine() ) != null && count < maxNumberOfLines;
                    count++ )
            {
                writer.println( line );
            }
            writer.close();
            return stringWriter.getBuffer().toString();
        }
        catch ( IOException e )
        {
            throw new RuntimeException( "Can't happen", e );
        }
    }

Try With Resources try(BufferedReader reader=new BufferedReader(new StringReader(string))) in method public firstLinesOf(string String, maxNumberOfLines int) : String from class org.neo4j.kernel.impl.util.DebugUtil


    public Iterable<String> getNodeLabels( long node )
    {
        return new IterableWrapper<>( database.getDatabase().getNodeById( node ).getLabels() )
        {
            @Override
            protected String underlyingObjectToObject( Label object )
            {
                return object.name();
            }
        };
    }

    public Iterable<String> getNodeLabels( long node )
    {
        return new IterableWrapper<String, Label>( database.getDatabase().getNodeById( node ).getLabels() )
        {
            @Override
            protected String underlyingObjectToObject( Label object )
            {
                return object.name();
            }
        };
    }

Replace Generic With Diamond IterableWrapper<String,Label> with IterableWrapper<> in method public getNodeLabels(node long) : Iterable<String> from class org.neo4j.server.rest.domain.GraphDbHelper


    @Override
    public Iterator<T> iterator()
    {
        return new PrefetchingIterator<>()
        {
            @Override
            protected T fetchNextOrNull()
            {
                if ( !relationshipCursor.next() )
                {
                    return null;
                }

                return nextFrom( relationshipCursor.entityReference(), relationshipCursor.type(),
                                 relationshipCursor.sourceNodeReference(), relationshipCursor.targetNodeReference() );
            }
        };
    }

    @Override
    public Iterator<T> iterator()
    {
        return new PrefetchingIterator<T>()
        {
            @Override
            protected T fetchNextOrNull()
            {
                if ( !relationshipCursor.next() )
                {
                    return null;
                }

                return nextFrom( relationshipCursor.entityReference(), relationshipCursor.type(),
                        relationshipCursor.sourceNodeReference(), relationshipCursor.targetNodeReference() );
            }
        };
    }

Replace Generic With Diamond PrefetchingIterator<T> with PrefetchingIterator<> in method public iterator() : Iterator<T> from class org.neo4j.batchinsert.internal.BatchRelationshipIterable


    @Override
    public ChannelInitializer<Channel> channelInitializer()
    {
        return new ChannelInitializer<>()
        {
            @Override
            public void initChannel( Channel ch )
            {
                ch.config().setAllocator( PooledByteBufAllocator.DEFAULT );

                BoltChannel boltChannel = newBoltChannel( ch );
                connectionTracker.add( boltChannel );
                ch.closeFuture().addListener( future -> connectionTracker.remove( boltChannel ) );

                // install throttles
                throttleGroup.install( ch );

                // add a close listener that will uninstall throttles
                ch.closeFuture().addListener( future -> throttleGroup.uninstall( ch ) );

                TransportSelectionHandler transportSelectionHandler = new TransportSelectionHandler( boltChannel, sslCtx,
                                                                                encryptionRequired, false, logging, boltProtocolFactory );

                ch.pipeline().addLast( transportSelectionHandler );
            }
        };
    }

    @Override
    public ChannelInitializer<Channel> channelInitializer()
    {
        return new ChannelInitializer<Channel>()
        {
            @Override
            public void initChannel( Channel ch )
            {
                ch.config().setAllocator( PooledByteBufAllocator.DEFAULT );

                BoltChannel boltChannel = newBoltChannel( ch );
                connectionTracker.add( boltChannel );
                ch.closeFuture().addListener( future -> connectionTracker.remove( boltChannel ) );

                // install throttles
                throttleGroup.install( ch );

                // add a close listener that will uninstall throttles
                ch.closeFuture().addListener( future -> throttleGroup.uninstall( ch ) );

                TransportSelectionHandler transportSelectionHandler = new TransportSelectionHandler( boltChannel, sslCtx,
                        encryptionRequired, false, logging, boltProtocolFactory );

                ch.pipeline().addLast( transportSelectionHandler );
            }
        };
    }

Replace Generic With Diamond ChannelInitializer<Channel> with ChannelInitializer<> in method public channelInitializer() : ChannelInitializer<Channel> from class org.neo4j.bolt.transport.SocketTransport


    private static String source( List<? extends Diagnostic<?>> diagnostics )
    {
        Set<JavaFileObject> sources = null;
        for ( Diagnostic<?> diagnostic : diagnostics )
        {
            Object source = diagnostic.getSource();
            if ( source instanceof JavaFileObject )
            {
                JavaFileObject file = (JavaFileObject) source;
                if ( file.getKind() == JavaFileObject.Kind.SOURCE )
                {
                    if ( sources == null )
                    {
                        sources = Collections.newSetFromMap( new IdentityHashMap<>() );
                    }
                    sources.add( file );
                }
            }
        }
        if ( sources == null )
        {
            return "";
        }
        StringBuilder result = new StringBuilder();
        for ( JavaFileObject source : sources )
        {
            int pos = result.length();
            result.append( "\nSource file " ).append( source.getName() ).append( ":\n" );
            try
            {
                CharSequence content = source.getCharContent( true );
                result.append( String.format( "%4d: ", 1 ) );
                for ( int line = 1, i = 0; i < content.length(); i++ )
                {
                    char c = content.charAt( i );
                    result.append( c );
                    if ( c == '\n' )
                    {
                        result.append( String.format( "%4d: ", ++line ) );
                    }
                }
            }
            catch ( IOException e )
            {
                result.setLength( pos );
            }
        }
        return result.toString();
    }

    private static String source( List<? extends Diagnostic<?>> diagnostics )
    {
        Set<JavaFileObject> sources = null;
        for ( Diagnostic<?> diagnostic : diagnostics )
        {
            Object source = diagnostic.getSource();
            if ( source instanceof JavaFileObject )
            {
                JavaFileObject file = (JavaFileObject) source;
                if ( file.getKind() == JavaFileObject.Kind.SOURCE )
                {
                    if ( sources == null )
                    {
                        sources = Collections.newSetFromMap( new IdentityHashMap<JavaFileObject,Boolean>() );
                    }
                    sources.add( file );
                }
            }
        }
        if ( sources == null )
        {
            return "";
        }
        StringBuilder result = new StringBuilder();
        for ( JavaFileObject source : sources )
        {
            int pos = result.length();
            result.append( "\nSource file " ).append( source.getName() ).append( ":\n" );
            try
            {
                CharSequence content = source.getCharContent( true );
                result.append( String.format( "%4d: ", 1 ) );
                for ( int line = 1, i = 0; i < content.length(); i++ )
                {
                    char c = content.charAt( i );
                    result.append( c );
                    if ( c == '\n' )
                    {
                        result.append( String.format( "%4d: ", ++line ) );
                    }
                }
            }
            catch ( IOException e )
            {
                result.setLength( pos );
            }
        }
        return result.toString();
    }

Replace Generic With Diamond IdentityHashMap<JavaFileObject,Boolean> with IdentityHashMap<> in method private source(diagnostics List<? extends Diagnostic<?>>) : String from class org.neo4j.codegen.CompilationFailureException


    /**
     * Creates a lazy initialized {@link Supplier} of a single object
     *
     * @param supplier A supplier that will provide the object when required
     * @param <T> The object type
     * @return A {@link Supplier} returning the specified object instance
     */
    public static <T> Lazy<T> lazySingleton( final Supplier<T> supplier )
    {
        return new Lazy<>()
        {
            volatile T instance;

            @Override
            public T get()
            {
                if ( isInitialised() )
                {
                    return instance;
                }

                synchronized ( this )
                {
                    if ( instance == null )
                    {
                        instance = supplier.get();
                    }
                }
                return instance;
            }

            @Override
            public boolean isInitialised()
            {
                return instance != null;
            }
        };
    }

    /**
     * Creates a lazy initialized {@link Supplier} of a single object
     *
     * @param supplier A supplier that will provide the object when required
     * @param <T> The object type
     * @return A {@link Supplier} returning the specified object instance
     */
    public static <T> Lazy<T> lazySingleton( final Supplier<T> supplier )
    {
        return new Lazy<T>()
        {
            volatile T instance;

            @Override
            public T get()
            {
                if ( isInitialised() )
                {
                    return instance;
                }

                synchronized ( this )
                {
                    if ( instance == null )
                    {
                        instance = supplier.get();
                    }
                }
                return instance;
            }

            @Override
            public boolean isInitialised()
            {
                return instance != null;
            }
        };
    }

Replace Generic With Diamond Lazy<T> with Lazy<> in method public lazySingleton(supplier Supplier<T>) : Lazy<T> from class org.neo4j.function.Suppliers


    /**
     * Creates a new {@link Supplier} that applies the specified function to the values obtained from a source supplier. The
     * function is only invoked once for every sequence of identical objects obtained from the source supplier (the previous result
     * is cached and returned again if the source object hasn't changed).
     *
     * @param supplier A supplier of source objects
     * @param adaptor A function mapping source objects to result objects
     * @param <V> The source object type
     * @param <T> The result object type
     * @return A {@link Supplier} of objects
     */
    public static <T, V> Supplier<T> adapted( final Supplier<V> supplier, final Function<V,T> adaptor )
    {
        return new Supplier<>()
        {
            volatile V lastValue;
            T instance;

            @Override
            public T get()
            {
                V value = supplier.get();
                if ( value == lastValue )
                {
                    return instance;
                }

                T adaptedValue = adaptor.apply( value );
                synchronized ( this )
                {
                    if ( value != lastValue )
                    {
                        instance = adaptedValue;
                        lastValue = value;
                    }
                }
                return instance;
            }
        };
    }

    /**
     * Creates a new {@link Supplier} that applies the specified function to the values obtained from a source supplier. The
     * function is only invoked once for every sequence of identical objects obtained from the source supplier (the previous result
     * is cached and returned again if the source object hasn't changed).
     *
     * @param supplier A supplier of source objects
     * @param adaptor A function mapping source objects to result objects
     * @param <V> The source object type
     * @param <T> The result object type
     * @return A {@link Supplier} of objects
     */
    public static <T, V> Supplier<T> adapted( final Supplier<V> supplier, final Function<V,T> adaptor )
    {
        return new Supplier<T>()
        {
            volatile V lastValue;
            T instance;

            @Override
            public T get()
            {
                V value = supplier.get();
                if ( value == lastValue )
                {
                    return instance;
                }

                T adaptedValue = adaptor.apply( value );
                synchronized ( this )
                {
                    if ( value != lastValue )
                    {
                        instance = adaptedValue;
                        lastValue = value;
                    }
                }
                return instance;
            }
        };
    }

Replace Generic With Diamond Supplier<T> with Supplier<> in method public adapted(supplier Supplier<V>, adaptor Function<V,T>) : Supplier<T> from class org.neo4j.function.Suppliers


    static <TYPE> ThrowingPredicate<TYPE,RuntimeException> throwingPredicate( Predicate<TYPE> predicate )
    {
        return new ThrowingPredicate<>()
        {
            @Override
            public boolean test( TYPE value )
            {
                return predicate.test( value );
            }

            @Override
            public String toString()
            {
                return predicate.toString();
            }
        };
    }

    static <TYPE> ThrowingPredicate<TYPE,RuntimeException> throwingPredicate( Predicate<TYPE> predicate )
    {
        return new ThrowingPredicate<TYPE,RuntimeException>()
        {
            @Override
            public boolean test( TYPE value )
            {
                return predicate.test( value );
            }

            @Override
            public String toString()
            {
                return predicate.toString();
            }
        };
    }

Replace Generic With Diamond ThrowingPredicate<TYPE,RuntimeException> with ThrowingPredicate<> in method public throwingPredicate(predicate Predicate<TYPE>) : ThrowingPredicate<TYPE,RuntimeException> from class org.neo4j.function.ThrowingPredicate


    static <TYPE> ThrowingSupplier<TYPE,RuntimeException> throwingSupplier( Supplier<TYPE> supplier )
    {
        return new ThrowingSupplier<>()
        {
            @Override
            public TYPE get()
            {
                return supplier.get();
            }

            @Override
            public String toString()
            {
                return supplier.toString();
            }
        };
    }

    static <TYPE> ThrowingSupplier<TYPE,RuntimeException> throwingSupplier( Supplier<TYPE> supplier )
    {
        return new ThrowingSupplier<TYPE,RuntimeException>()
        {
            @Override
            public TYPE get()
            {
                return supplier.get();
            }

            @Override
            public String toString()
            {
                return supplier.toString();
            }
        };
    }

Replace Generic With Diamond ThrowingSupplier<TYPE,RuntimeException> with ThrowingSupplier<> in method public throwingSupplier(supplier Supplier<TYPE>) : ThrowingSupplier<TYPE,RuntimeException> from class org.neo4j.function.ThrowingSupplier


    /**
     * Combine multiple @{link Future} instances into a single Future
     *
     * @param futures the @{link Future} instances to combine
     * @param <V>     The result type returned by this Future's get method
     * @return A new @{link Future} representing the combination
     */
    public static <V> Future<List<V>> combine( final Iterable<? extends Future<? extends V>> futures )
    {
        return new Future<>()
        {
            @Override
            public boolean cancel( boolean mayInterruptIfRunning )
            {
                boolean result = false;
                for ( Future<? extends V> future : futures )
                {
                    result |= future.cancel( mayInterruptIfRunning );
                }
                return result;
            }

            @Override
            public boolean isCancelled()
            {
                boolean result = false;
                for ( Future<? extends V> future : futures )
                {
                    result |= future.isCancelled();
                }
                return result;
            }

            @Override
            public boolean isDone()
            {
                boolean result = false;
                for ( Future<? extends V> future : futures )
                {
                    result |= future.isDone();
                }
                return result;
            }

            @Override
            public List<V> get() throws InterruptedException, ExecutionException
            {
                List<V> result = new ArrayList<>();
                for ( Future<? extends V> future : futures )
                {
                    result.add( future.get() );
                }
                return result;
            }

            @Override
            public List<V> get( long timeout, TimeUnit unit ) throws InterruptedException, ExecutionException, TimeoutException
            {
                List<V> result = new ArrayList<>();
                for ( Future<? extends V> future : futures )
                {
                    long before = System.nanoTime();
                    result.add( future.get( timeout, unit ) );
                    timeout -= unit.convert( System.nanoTime() - before, TimeUnit.NANOSECONDS );
                }
                return result;
            }
        };
    }

    /**
     * Combine multiple @{link Future} instances into a single Future
     *
     * @param futures the @{link Future} instances to combine
     * @param <V>     The result type returned by this Future's get method
     * @return A new @{link Future} representing the combination
     */
    public static <V> Future<List<V>> combine( final Iterable<? extends Future<? extends V>> futures )
    {
        return new Future<List<V>>()
        {
            @Override
            public boolean cancel( boolean mayInterruptIfRunning )
            {
                boolean result = false;
                for ( Future<? extends V> future : futures )
                {
                    result |= future.cancel( mayInterruptIfRunning );
                }
                return result;
            }

            @Override
            public boolean isCancelled()
            {
                boolean result = false;
                for ( Future<? extends V> future : futures )
                {
                    result |= future.isCancelled();
                }
                return result;
            }

            @Override
            public boolean isDone()
            {
                boolean result = false;
                for ( Future<? extends V> future : futures )
                {
                    result |= future.isDone();
                }
                return result;
            }

            @Override
            public List<V> get() throws InterruptedException, ExecutionException
            {
                List<V> result = new ArrayList<>();
                for ( Future<? extends V> future : futures )
                {
                    result.add( future.get() );
                }
                return result;
            }

            @Override
            public List<V> get( long timeout, TimeUnit unit ) throws InterruptedException, ExecutionException, TimeoutException
            {
                List<V> result = new ArrayList<>();
                for ( Future<? extends V> future : futures )
                {
                    long before = System.nanoTime();
                    result.add( future.get( timeout, unit ) );
                    timeout -= unit.convert( System.nanoTime() - before, TimeUnit.NANOSECONDS );
                }
                return result;
            }
        };
    }

Replace Generic With Diamond Future<List<V>> with Future<> in method public combine(futures Iterable<? extends Future<? extends V>>) : Future<List<V>> from class org.neo4j.util.concurrent.Futures


    private static ComparativeRecordChecker<PropertyRecord, PropertyKeyTokenRecord, ConsistencyReport.PropertyConsistencyReport>
    propertyKey( final PropertyBlock block )
    {
        return new ComparativeRecordChecker<>()
        {
            @Override
            public void checkReference( PropertyRecord record, PropertyKeyTokenRecord referred,
                                        CheckerEngine<PropertyRecord,ConsistencyReport.PropertyConsistencyReport> engine,
                                        RecordAccess records )
            {
                if ( !referred.inUse() )
                {
                    engine.report().keyNotInUse( block, referred );
                }
            }

            @Override
            public String toString()
            {
                return "PROPERTY_KEY";
            }
        };
    }

    private static ComparativeRecordChecker<PropertyRecord, PropertyKeyTokenRecord, ConsistencyReport.PropertyConsistencyReport>
    propertyKey( final PropertyBlock block )
    {
        return new ComparativeRecordChecker<PropertyRecord, PropertyKeyTokenRecord, ConsistencyReport.PropertyConsistencyReport>()
        {
            @Override
            public void checkReference( PropertyRecord record, PropertyKeyTokenRecord referred,
                                        CheckerEngine<PropertyRecord, ConsistencyReport.PropertyConsistencyReport> engine,
                                        RecordAccess records )
            {
                if ( !referred.inUse() )
                {
                    engine.report().keyNotInUse( block, referred );
                }
            }

            @Override
            public String toString()
            {
                return "PROPERTY_KEY";
            }
        };
    }

Replace Generic With Diamond ComparativeRecordChecker<PropertyRecord,PropertyKeyTokenRecord,ConsistencyReport.PropertyConsistencyReport> with ComparativeRecordChecker<> in method private propertyKey(block PropertyBlock) : ComparativeRecordChecker<PropertyRecord,PropertyKeyTokenRecord,ConsistencyReport.PropertyConsistencyReport> from class org.neo4j.consistency.checking.PropertyRecordCheck


    public static <RECORD extends AbstractBaseRecord, REPORT extends ConsistencyReport> Set<Long> getListOfLabels(
            NodeRecord nodeRecord, RecordAccess records, CheckerEngine<RECORD, REPORT> engine )
    {
        final Set<Long> labels = new HashSet<>();

        NodeLabels nodeLabels = NodeLabelsField.parseLabelsField( nodeRecord );
        if ( nodeLabels instanceof DynamicNodeLabels )
        {

            DynamicNodeLabels dynamicNodeLabels = (DynamicNodeLabels) nodeLabels;
            long firstRecordId = dynamicNodeLabels.getFirstDynamicRecordId();
            RecordReference<DynamicRecord> firstRecordReference = records.nodeLabels( firstRecordId );
            engine.comparativeCheck( firstRecordReference,
                    new LabelChainWalker<>(
                            new LabelChainWalker.Validator<>()
                            {
                                @Override
                                public void onRecordNotInUse( DynamicRecord dynamicRecord,
                                                              CheckerEngine<RECORD,REPORT> engine )
                                {
                                }

                                @Override
                                public void onRecordChainCycle( DynamicRecord record,
                                                                CheckerEngine<RECORD,REPORT> engine )
                                {
                                }

                                @Override
                                public void onWellFormedChain( long[] labelIds,
                                                               CheckerEngine<RECORD,REPORT> engine,
                                                               RecordAccess records )
                                {
                                    copyToSet( labelIds, labels );
                                }
                            } ) );
        }
        else
        {
            copyToSet( nodeLabels.get( null ), labels );
        }

        return labels;
    }

    public static <RECORD extends AbstractBaseRecord, REPORT extends ConsistencyReport> Set<Long> getListOfLabels(
            NodeRecord nodeRecord, RecordAccess records, CheckerEngine<RECORD, REPORT> engine )
    {
        final Set<Long> labels = new HashSet<>();

        NodeLabels nodeLabels = NodeLabelsField.parseLabelsField( nodeRecord );
        if ( nodeLabels instanceof DynamicNodeLabels )
        {

            DynamicNodeLabels dynamicNodeLabels = (DynamicNodeLabels) nodeLabels;
            long firstRecordId = dynamicNodeLabels.getFirstDynamicRecordId();
            RecordReference<DynamicRecord> firstRecordReference = records.nodeLabels( firstRecordId );
            engine.comparativeCheck( firstRecordReference,
                    new LabelChainWalker<>(
                            new LabelChainWalker.Validator<RECORD, REPORT>()
                            {
                                @Override
                                public void onRecordNotInUse( DynamicRecord dynamicRecord,
                                                              CheckerEngine<RECORD, REPORT> engine )
                                {
                                }

                                @Override
                                public void onRecordChainCycle( DynamicRecord record,
                                                                CheckerEngine<RECORD, REPORT> engine )
                                {
                                }

                                @Override
                                public void onWellFormedChain( long[] labelIds,
                                                               CheckerEngine<RECORD, REPORT> engine,
                                                               RecordAccess records )
                                {
                                    copyToSet( labelIds, labels );
                                }
                            } ) );
        }
        else
        {
            copyToSet( nodeLabels.get( null ), labels );
        }

        return labels;
    }

Replace Generic With Diamond LabelChainWalker<> with LabelChainWalker<> in method public getListOfLabels(nodeRecord NodeRecord, records RecordAccess, engine CheckerEngine<RECORD,REPORT>) : Set<Long> from class org.neo4j.consistency.checking.full.NodeLabelReader


    <R extends AbstractBaseRecord> void applyFilteredParallel( RecordStore<R> store, ProgressListener progressListener, int numberOfThreads,
            long recordsPerCpu, final QueueDistributor<R> distributor )
    {
        cacheAccess.prepareForProcessingOfSingleStore( recordsPerCpu );
        RecordProcessor<R> processor = new RecordProcessor.Adapter<>()
        {
            @Override
            public void init( int id )
            {
                // Thread id assignment happens here, so do this before processing. Calles to this init
                // method is ordered externally.
                cacheAccess.client();
            }

            @Override
            public void process( R record )
            {
                store.accept( StoreProcessor.this, record );
            }
        };

        ResourceIterable<R> scan = scan( store, stage.isForward() );
        try ( ResourceIterator<R> records = scan.iterator() )
        {
            distributeRecords( numberOfThreads, getClass().getSimpleName(), DEFAULT_QUEUE_SIZE,
                    cloned( records ), progressListener, processor, distributor );
        }
    }

    <R extends AbstractBaseRecord> void applyFilteredParallel( RecordStore<R> store, ProgressListener progressListener, int numberOfThreads,
            long recordsPerCpu, final QueueDistributor<R> distributor )
    {
        cacheAccess.prepareForProcessingOfSingleStore( recordsPerCpu );
        RecordProcessor<R> processor = new RecordProcessor.Adapter<R>()
        {
            @Override
            public void init( int id )
            {
                // Thread id assignment happens here, so do this before processing. Calles to this init
                // method is ordered externally.
                cacheAccess.client();
            }

            @Override
            public void process( R record )
            {
                store.accept( StoreProcessor.this, record );
            }
        };

        ResourceIterable<R> scan = scan( store, stage.isForward() );
        try ( ResourceIterator<R> records = scan.iterator() )
        {
            distributeRecords( numberOfThreads, getClass().getSimpleName(), DEFAULT_QUEUE_SIZE,
                    cloned( records ), progressListener, processor, distributor );
        }
    }

Replace Generic With Diamond RecordProcessor.Adapter<R> with RecordProcessor.Adapter<> in method package applyFilteredParallel(store RecordStore<R>, progressListener ProgressListener, numberOfThreads int, recordsPerCpu long, distributor QueueDistributor<R>) : void from class org.neo4j.consistency.checking.full.StoreProcessor


    public <RECORD extends AbstractBaseRecord,REPORT extends ConsistencyReport> REPORT report( RECORD record,
            Class<REPORT> cls, RecordType recordType )
    {
        ProxyFactory<REPORT> proxyFactory = ProxyFactory.get( cls );
        ReportInvocationHandler<RECORD,REPORT> handler =
                new ReportHandler<>( report, proxyFactory, recordType, records, record, monitor )
                {
                    @Override
                    protected void inconsistencyReported()
                    {
                        updateSummary();
                    }
                };
        return handler.report();
    }

    public <RECORD extends AbstractBaseRecord,REPORT extends ConsistencyReport> REPORT report( RECORD record,
            Class<REPORT> cls, RecordType recordType )
    {
        ProxyFactory<REPORT> proxyFactory = ProxyFactory.get( cls );
        ReportInvocationHandler<RECORD,REPORT> handler =
                new ReportHandler<RECORD,REPORT>( report, proxyFactory, recordType, records, record, monitor )
        {
            @Override
            protected void inconsistencyReported()
            {
                updateSummary();
            }
        };
        return handler.report();
    }

Replace Generic With Diamond ReportHandler<RECORD,REPORT> with ReportHandler<> in method public report(record RECORD, cls Class<REPORT>, recordType RecordType) : REPORT from class org.neo4j.consistency.report.ConsistencyReporter


    @Override
    public Iterator<PropertyRecord> rawPropertyChain( final long firstId )
    {
        return new PrefetchingIterator<>()
        {
            private long next = firstId;

            @Override
            protected PropertyRecord fetchNextOrNull()
            {
                if ( Record.NO_NEXT_PROPERTY.is( next ) )
                {
                    return null;
                }

                PropertyRecord record = referenceTo( access.getPropertyStore(), next ).record();
                next = record.getNextProp();
                return record;
            }
        };
    }

    @Override
    public Iterator<PropertyRecord> rawPropertyChain( final long firstId )
    {
        return new PrefetchingIterator<PropertyRecord>()
        {
            private long next = firstId;

            @Override
            protected PropertyRecord fetchNextOrNull()
            {
                if ( Record.NO_NEXT_PROPERTY.is( next ) )
                {
                    return null;
                }

                PropertyRecord record = referenceTo( access.getPropertyStore(), next ).record();
                next = record.getNextProp();
                return record;
            }
        };
    }

Replace Generic With Diamond PrefetchingIterator<PropertyRecord> with PrefetchingIterator<> in method public rawPropertyChain(firstId long) : Iterator<PropertyRecord> from class org.neo4j.consistency.store.DirectRecordAccess


    @SafeVarargs
    public static <IN,OUT> RawIterator<OUT,IOException> iterator( ThrowingFunction<IN,OUT,IOException> converter, IN... items )
    {
        if ( items.length == 0 )
        {
            throw new IllegalStateException( "No source items specified" );
        }

        return new RawIterator<>()
        {
            private int cursor;

            @Override
            public boolean hasNext()
            {
                return cursor < items.length;
            }

            @Override
            public OUT next() throws IOException
            {
                if ( !hasNext() )
                {
                    throw new IllegalStateException();
                }
                return converter.apply( items[cursor++] );
            }

            @Override
            public void remove()
            {
                throw new UnsupportedOperationException();
            }
        };
    }

    @SafeVarargs
    public static <IN,OUT> RawIterator<OUT,IOException> iterator( ThrowingFunction<IN,OUT,IOException> converter, IN... items )
    {
        if ( items.length == 0 )
        {
            throw new IllegalStateException( "No source items specified" );
        }

        return new RawIterator<OUT,IOException>()
        {
            private int cursor;

            @Override
            public boolean hasNext()
            {
                return cursor < items.length;
            }

            @Override
            public OUT next() throws IOException
            {
                if ( !hasNext() )
                {
                    throw new IllegalStateException();
                }
                return converter.apply( items[cursor++] );
            }

            @Override
            public void remove()
            {
                throw new UnsupportedOperationException();
            }
        };
    }

Replace Generic With Diamond RawIterator<OUT,IOException> with RawIterator<> in method public iterator(converter ThrowingFunction<IN,OUT,IOException>, items IN...) : RawIterator<OUT,IOException> from class org.neo4j.csv.reader.Readables


            @Override
            public Iterator<PropertyContainer> iterator()
            {
                return new Iterator<>()
                {
                    Iterator<? extends PropertyContainer> current = nodes().iterator();
                    Iterator<? extends PropertyContainer> next = relationships().iterator();

                    @Override
                    public boolean hasNext()
                    {
                        return current.hasNext();
                    }

                    @Override
                    public PropertyContainer next()
                    {
                        try
                        {
                            return current.next();
                        }
                        finally
                        {
                            Iterator<? extends PropertyContainer> temp = current;
                            current = next;
                            next = temp;
                        }
                    }

                    @Override
                    public void remove()
                    {
                        next.remove();
                    }
                };
            }

            @Override
            public Iterator<PropertyContainer> iterator()
            {
                return new Iterator<PropertyContainer>()
                {
                    Iterator<? extends PropertyContainer> current = nodes().iterator();
                    Iterator<? extends PropertyContainer> next = relationships().iterator();

                    @Override
                    public boolean hasNext()
                    {
                        return current.hasNext();
                    }

                    @Override
                    public PropertyContainer next()
                    {
                        try
                        {
                            return current.next();
                        }
                        finally
                        {
                            Iterator<? extends PropertyContainer> temp = current;
                            current = next;
                            next = temp;
                        }
                    }

                    @Override
                    public void remove()
                    {
                        next.remove();
                    }
                };
            }

Replace Generic With Diamond Iterator<PropertyContainer> with Iterator<> in method public iterator() : Iterator<PropertyContainer> from class org.neo4j.cypher.internal.codegen.ParameterConverter.writePath.writeValue.new Path


    @Override
    public void writePath( NodeValue[] nodes, RelationshipValue[] relationships )
    {
        assert nodes != null;
        assert nodes.length > 0;
        assert relationships != null;
        assert nodes.length == relationships.length + 1;

        Node[] nodeProxies = new Node[nodes.length];
        for ( int i = 0; i < nodes.length; i++ )
        {
            nodeProxies[i] = proxySpi.newNodeProxy( nodes[i].id() );
        }
        Relationship[] relationship = new Relationship[relationships.length];
        for ( int i = 0; i < relationships.length; i++ )
        {
            relationship[i] = proxySpi.newRelationshipProxy( relationships[i].id() );
        }
        writeValue( new Path()
        {
            @Override
            public Node startNode()
            {
                return nodeProxies[0];
            }

            @Override
            public Node endNode()
            {
                return nodeProxies[nodeProxies.length - 1];
            }

            @Override
            public Relationship lastRelationship()
            {
                return relationship[relationship.length - 1];
            }

            @Override
            public Iterable<Relationship> relationships()
            {
                return Arrays.asList( relationship );
            }

            @Override
            public Iterable<Relationship> reverseRelationships()
            {
                return () -> new ReverseArrayIterator<>( relationship );
            }

            @Override
            public Iterable<Node> nodes()
            {
                return Arrays.asList( nodeProxies );
            }

            @Override
            public Iterable<Node> reverseNodes()
            {
                return () -> new ReverseArrayIterator<>( nodeProxies );
            }

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

            @Override
            public int hashCode()
            {
                if ( relationship.length == 0 )
                {
                    return startNode().hashCode();
                }
                else
                {
                    return Arrays.hashCode( relationship );
                }
            }

            @Override
            public boolean equals( Object obj )
            {
                if ( this == obj )
                {
                    return true;
                }
                else if ( obj instanceof Path )
                {
                    Path other = (Path) obj;
                    return startNode().equals( other.startNode() ) &&
                           iteratorsEqual( this.relationships().iterator(), other.relationships().iterator() );

                }
                else
                {
                    return false;
                }
            }

            @Override
            public Iterator<PropertyContainer> iterator()
            {
                return new Iterator<>()
                {
                    Iterator<? extends PropertyContainer> current = nodes().iterator();
                    Iterator<? extends PropertyContainer> next = relationships().iterator();

                    @Override
                    public boolean hasNext()
                    {
                        return current.hasNext();
                    }

                    @Override
                    public PropertyContainer next()
                    {
                        try
                        {
                            return current.next();
                        }
                        finally
                        {
                            Iterator<? extends PropertyContainer> temp = current;
                            current = next;
                            next = temp;
                        }
                    }

                    @Override
                    public void remove()
                    {
                        next.remove();
                    }
                };
            }
        } );
    }

    @Override
    public void writePath( NodeValue[] nodes, RelationshipValue[] relationships )
    {
        assert nodes != null;
        assert nodes.length > 0;
        assert relationships != null;
        assert nodes.length == relationships.length + 1;

        Node[] nodeProxies = new Node[nodes.length];
        for ( int i = 0; i < nodes.length; i++ )
        {
            nodeProxies[i] = proxySpi.newNodeProxy( nodes[i].id() );
        }
        Relationship[] relationship = new Relationship[relationships.length];
        for ( int i = 0; i < relationships.length; i++ )
        {
            relationship[i] = proxySpi.newRelationshipProxy( relationships[i].id() );
        }
        writeValue( new Path()
        {
            @Override
            public Node startNode()
            {
                return nodeProxies[0];
            }

            @Override
            public Node endNode()
            {
                return nodeProxies[nodeProxies.length - 1];
            }

            @Override
            public Relationship lastRelationship()
            {
                return relationship[relationship.length - 1];
            }

            @Override
            public Iterable<Relationship> relationships()
            {
                return Arrays.asList( relationship );
            }

            @Override
            public Iterable<Relationship> reverseRelationships()
            {
                return () -> new ReverseArrayIterator<>( relationship );
            }

            @Override
            public Iterable<Node> nodes()
            {
                return Arrays.asList( nodeProxies );
            }

            @Override
            public Iterable<Node> reverseNodes()
            {
                return () -> new ReverseArrayIterator<>( nodeProxies );
            }

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

            @Override
            public int hashCode()
            {
                if ( relationship.length == 0 )
                {
                    return startNode().hashCode();
                }
                else
                {
                    return Arrays.hashCode( relationship );
                }
            }

            @Override
            public boolean equals( Object obj )
            {
                if ( this == obj )
                {
                    return true;
                }
                else if ( obj instanceof Path )
                {
                    Path other = (Path) obj;
                    return startNode().equals( other.startNode() ) &&
                           iteratorsEqual( this.relationships().iterator(), other.relationships().iterator() );

                }
                else
                {
                    return false;
                }
            }

            @Override
            public Iterator<PropertyContainer> iterator()
            {
                return new Iterator<PropertyContainer>()
                {
                    Iterator<? extends PropertyContainer> current = nodes().iterator();
                    Iterator<? extends PropertyContainer> next = relationships().iterator();

                    @Override
                    public boolean hasNext()
                    {
                        return current.hasNext();
                    }

                    @Override
                    public PropertyContainer next()
                    {
                        try
                        {
                            return current.next();
                        }
                        finally
                        {
                            Iterator<? extends PropertyContainer> temp = current;
                            current = next;
                            next = temp;
                        }
                    }

                    @Override
                    public void remove()
                    {
                        next.remove();
                    }
                };
            }
        } );
    }

Replace Generic With Diamond Iterator<PropertyContainer> with Iterator<> in method public writePath(nodes NodeValue[], relationships RelationshipValue[]) : void from class org.neo4j.cypher.internal.codegen.ParameterConverter


    @Override
    public Iterator<T> iterator()
    {
        if ( count == -1 )
        {
            // This should never happen in generated code but is here to simplify debugging if used incorrectly
            throw new IllegalStateException( "sort() needs to be called before requesting an iterator" );
        }
        return new Iterator<>()
        {
            private int cursor = count;

            @Override
            public boolean hasNext()
            {
                return cursor > 0;
            }

            @Override
            @SuppressWarnings( "unchecked" )
            public T next()
            {
                if ( !hasNext() )
                {
                    throw new NoSuchElementException();
                }

                int offset = --cursor;
                return (T) array[offset];
            }
        };
    }

    @Override
    public Iterator<T> iterator()
    {
        if ( count == -1 )
        {
            // This should never happen in generated code but is here to simplify debugging if used incorrectly
            throw new IllegalStateException( "sort() needs to be called before requesting an iterator" );
        }
        return new Iterator<T>()
        {
            private int cursor = count;

            @Override
            public boolean hasNext()
            {
                return cursor > 0;
            }

            @Override
            @SuppressWarnings( "unchecked" )
            public T next()
            {
                if ( !hasNext() )
                {
                    throw new NoSuchElementException();
                }

                int offset = --cursor;
                return (T) array[offset];
            }
        };
    }

Replace Generic With Diamond Iterator<T> with Iterator<> in method public iterator() : Iterator<T> from class org.neo4j.cypher.internal.DefaultComparatorTopTable


    public static <P extends Comparable<? super P>> PathInterest<P> numberOfShortest( final int numberOfWantedPaths )
    {
        if ( numberOfWantedPaths < 1 )
        {
            throw new IllegalArgumentException( "Can not create PathInterest with interested in less than 1 path." );
        }

        return new VisitCountBasedPathInterest<>()
        {
            private Comparator<P> comparator = Comparable::compareTo;

            @Override
            int numberOfWantedPaths()
            {
                return numberOfWantedPaths;
            }

            @Override
            public Comparator<P> comparator()
            {
                return comparator;
            }
        };
    }

    public static <P extends Comparable<? super P>> PathInterest<P> numberOfShortest( final int numberOfWantedPaths )
    {
        if ( numberOfWantedPaths < 1 )
        {
            throw new IllegalArgumentException( "Can not create PathInterest with interested in less than 1 path." );
        }

        return new VisitCountBasedPathInterest<P>()
        {
            private Comparator<P> comparator = Comparable::compareTo;

            @Override
            int numberOfWantedPaths()
            {
                return numberOfWantedPaths;
            }

            @Override
            public Comparator<P> comparator()
            {
                return comparator;
            }
        };
    }

Replace Generic With Diamond VisitCountBasedPathInterest<P> with VisitCountBasedPathInterest<> in method public numberOfShortest(numberOfWantedPaths int) : PathInterest<P> from class org.neo4j.graphalgo.impl.util.PathInterestFactory


    /**
     * An expander forcing constant relationship direction
     *
     * @param types types of relationships to follow
     * @param <STATE> the type of the object that holds the state
     * @return a {@link PathExpander} which enforces constant relationship direction
     */
    public static <STATE> PathExpander<STATE> forConstantDirectionWithTypes( final RelationshipType... types )
    {
        return new PathExpander<>()
        {
            @Override
            public Iterable<Relationship> expand( Path path, BranchState<STATE> state )
            {
                if ( path.length() == 0 )
                {
                    return path.endNode().getRelationships( types );
                }
                else
                {
                    Direction direction = getDirectionOfLastRelationship( path );
                    return path.endNode().getRelationships( direction, types );
                }
            }

            @Override
            public PathExpander<STATE> reverse()
            {
                return this;
            }

            private Direction getDirectionOfLastRelationship( Path path )
            {
                assert path.length() > 0;
                Direction direction = Direction.INCOMING;
                if ( path.endNode().equals( path.lastRelationship().getEndNode() ) )
                {
                    direction = Direction.OUTGOING;
                }
                return direction;
            }
        };
    }

    /**
     * An expander forcing constant relationship direction
     *
     * @param types types of relationships to follow
     * @param <STATE> the type of the object that holds the state
     * @return a {@link PathExpander} which enforces constant relationship direction
     */
    public static <STATE> PathExpander<STATE> forConstantDirectionWithTypes( final RelationshipType... types )
    {
        return new PathExpander<STATE>()
        {
            @Override
            public Iterable<Relationship> expand( Path path, BranchState<STATE> state )
            {
                if ( path.length() == 0 )
                {
                    return path.endNode().getRelationships( types );
                }
                else
                {
                    Direction direction = getDirectionOfLastRelationship( path );
                    return path.endNode().getRelationships( direction, types );
                }
            }

            @Override
            public PathExpander<STATE> reverse()
            {
                return this;
            }

            private Direction getDirectionOfLastRelationship( Path path )
            {
                assert path.length() > 0;
                Direction direction = Direction.INCOMING;
                if ( path.endNode().equals( path.lastRelationship().getEndNode() ) )
                {
                    direction = Direction.OUTGOING;
                }
                return direction;
            }
        };
    }

Replace Generic With Diamond PathExpander<STATE> with PathExpander<> in method public forConstantDirectionWithTypes(types RelationshipType...) : PathExpander<STATE> from class org.neo4j.graphdb.PathExpanders