    /**
     * Loads a {@link Map} from a {@link Reader} assuming strings as keys
     * and values.
     *
     * @param reader the {@link Reader} containing a {@link Properties}-like
     * layout of keys and values.
     * @return the read data as a {@link Map}.
     * @throws IOException if the {@code reader} throws {@link IOException}.
     */
    public static Map<String, String> load( Reader reader ) throws IOException
    {
        Properties props = new Properties();
        props.load( reader );
        return new HashMap<>( (Map) props );
    }

    /**
     * Loads a {@link Map} from a {@link Reader} assuming strings as keys
     * and values.
     *
     * @param reader the {@link Reader} containing a {@link Properties}-like
     * layout of keys and values.
     * @return the read data as a {@link Map}.
     * @throws IOException if the {@code reader} throws {@link IOException}.
     */
    public static Map<String, String> load( Reader reader ) throws IOException
    {
        Properties props = new Properties();
        props.load( reader );
        return new HashMap<String, String>( (Map) props );
    }

Replace Generic With Diamond HashMap<String,String> with HashMap<> in method public load(reader Reader) : Map<String,String> from class org.neo4j.helpers.collection.MapUtil


    /**
     * Loads a {@link Map} from an {@link InputStream} assuming strings as keys
     * and values.
     *
     * @param stream the {@link InputStream} containing a
     * {@link Properties}-like layout of keys and values.
     * @return the read data as a {@link Map}.
     * @throws IOException if the {@code stream} throws {@link IOException}.
     */
    public static Map<String, String> load( InputStream stream ) throws IOException
    {
        Properties props = new Properties();
        props.load( stream );
        return new HashMap<>( (Map) props );
    }

    /**
     * Loads a {@link Map} from an {@link InputStream} assuming strings as keys
     * and values.
     *
     * @param stream the {@link InputStream} containing a
     * {@link Properties}-like layout of keys and values.
     * @return the read data as a {@link Map}.
     * @throws IOException if the {@code stream} throws {@link IOException}.
     */
    public static Map<String, String> load( InputStream stream ) throws IOException
    {
        Properties props = new Properties();
        props.load( stream );
        return new HashMap<String, String>( (Map) props );
    }

Replace Generic With Diamond HashMap<String,String> with HashMap<> in method public load(stream InputStream) : Map<String,String> from class org.neo4j.helpers.collection.MapUtil


    /**
     * Reversed a map, making the key value and the value key.
     * @param <K> the type of key in the map to reverse. These will be the
     * values in the returned map.
     * @param <V> the type of values in the map to revert. These will be the
     * keys in the returned map.
     * @param map the {@link Map} to reverse.
     * @return the reverse of {@code map}. A new {@link Map} will be returned
     * where the keys from {@code map} will be the values and the values will
     * be the keys.
     */
    public static <K, V> Map<V, K> reverse( Map<K, V> map )
    {
        Map<V, K> reversedMap = new HashMap<>();
        for ( Map.Entry<K, V> entry : map.entrySet() )
        {
            reversedMap.put( entry.getValue(), entry.getKey() );
        }
        return reversedMap;
    }

    /**
     * Reversed a map, making the key value and the value key.
     * @param <K> the type of key in the map to reverse. These will be the
     * values in the returned map.
     * @param <V> the type of values in the map to revert. These will be the
     * keys in the returned map.
     * @param map the {@link Map} to reverse.
     * @return the reverse of {@code map}. A new {@link Map} will be returned
     * where the keys from {@code map} will be the values and the values will
     * be the keys.
     */
    public static <K, V> Map<V, K> reverse( Map<K, V> map )
    {
        Map<V, K> reversedMap = new HashMap<V, K>();
        for ( Map.Entry<K, V> entry : map.entrySet() )
        {
            reversedMap.put( entry.getValue(), entry.getKey() );
        }
        return reversedMap;
    }

Replace Generic With Diamond HashMap<V,K> with HashMap<> in method public reverse(map Map<K,V>) : Map<V,K> from class org.neo4j.helpers.collection.MapUtil


    public static <K, V> Map<K, V> copyAndPut(Map<K, V> map, K key, V value)
    {
        Map<K, V> copy = new HashMap<>( map );
        copy.put( key,  value);
        return copy;
    }

    public static <K, V> Map<K, V> copyAndPut(Map<K, V> map, K key, V value)
    {
        Map<K, V> copy = new HashMap<K, V>( map );
        copy.put( key,  value);
        return copy;
    }

Replace Generic With Diamond HashMap<K,V> with HashMap<> in method public copyAndPut(map Map<K,V>, key K, value V) : Map<K,V> from class org.neo4j.helpers.collection.MapUtil


    public static <K, V> Map<K, V> copyAndRemove(Map<K, V> map, K key)
    {
        Map<K, V> copy = new HashMap<>( map );
        copy.remove( key );
        return copy;
    }

    public static <K, V> Map<K, V> copyAndRemove(Map<K, V> map, K key)
    {
        Map<K, V> copy = new HashMap<K, V>( map );
        copy.remove( key );
        return copy;
    }

Replace Generic With Diamond HashMap<K,V> with HashMap<> in method public copyAndRemove(map Map<K,V>, key K) : Map<K,V> from class org.neo4j.helpers.collection.MapUtil


    /**
     * Returns an {@link Evaluator} which compares the type of the last relationship
     * in a {@link Path} to a given set of relationship types (one or more).If the type of
     * the last relationship in a path is of one of the given types then
     * {@code evaluationIfMatch} will be returned, otherwise
     * {@code evaluationIfNoMatch} will be returned.
     *
     * @param evaluationIfMatch   the {@link Evaluation} to return if the type of the
     *                            last relationship in the path matches any of the given types.
     * @param evaluationIfNoMatch the {@link Evaluation} to return if the type of the
     *                            last relationship in the path doesn't match any of the given types.
     * @param type                the (first) type (of possibly many) to match the last relationship
     *                            in paths with.
     * @param orAnyOfTheseTypes   additional types to match the last relationship in
     *                            paths with.
     * @return an {@link Evaluator} which compares the type of the last relationship
     *         in a {@link Path} to a given set of relationship types.
     */
    @SuppressWarnings( "rawtypes" )
    public static PathEvaluator lastRelationshipTypeIs( final Evaluation evaluationIfMatch,
            final Evaluation evaluationIfNoMatch, final RelationshipType type, RelationshipType... orAnyOfTheseTypes )
    {
        if ( orAnyOfTheseTypes.length == 0 )
        {
            return new PathEvaluator.Adapter()
            {
                @Override
                public Evaluation evaluate( Path path, BranchState state )
                {
                    Relationship rel = path.lastRelationship();
                    return rel != null && rel.isType( type ) ? evaluationIfMatch : evaluationIfNoMatch;
                }
            };
        }

        final Set<String> expectedTypes = new HashSet<>();
        expectedTypes.add( type.name() );
        for ( RelationshipType otherType : orAnyOfTheseTypes )
        {
            expectedTypes.add( otherType.name() );
        }

        return new PathEvaluator.Adapter()
        {
            @Override
            public Evaluation evaluate( Path path, BranchState state )
            {
                Relationship lastRelationship = path.lastRelationship();
                if ( lastRelationship == null )
                {
                    return evaluationIfNoMatch;
                }

                return expectedTypes.contains( lastRelationship.getType().name() ) ?
                        evaluationIfMatch : evaluationIfNoMatch;
            }
        };
    }

    /**
     * Returns an {@link Evaluator} which compares the type of the last relationship
     * in a {@link Path} to a given set of relationship types (one or more).If the type of
     * the last relationship in a path is of one of the given types then
     * {@code evaluationIfMatch} will be returned, otherwise
     * {@code evaluationIfNoMatch} will be returned.
     *
     * @param evaluationIfMatch   the {@link Evaluation} to return if the type of the
     *                            last relationship in the path matches any of the given types.
     * @param evaluationIfNoMatch the {@link Evaluation} to return if the type of the
     *                            last relationship in the path doesn't match any of the given types.
     * @param type                the (first) type (of possibly many) to match the last relationship
     *                            in paths with.
     * @param orAnyOfTheseTypes   additional types to match the last relationship in
     *                            paths with.
     * @return an {@link Evaluator} which compares the type of the last relationship
     *         in a {@link Path} to a given set of relationship types.
     */
    @SuppressWarnings( "rawtypes" )
    public static PathEvaluator lastRelationshipTypeIs( final Evaluation evaluationIfMatch,
            final Evaluation evaluationIfNoMatch, final RelationshipType type, RelationshipType... orAnyOfTheseTypes )
    {
        if ( orAnyOfTheseTypes.length == 0 )
        {
            return new PathEvaluator.Adapter()
            {
                @Override
                public Evaluation evaluate( Path path, BranchState state )
                {
                    Relationship rel = path.lastRelationship();
                    return rel != null && rel.isType( type ) ? evaluationIfMatch : evaluationIfNoMatch;
                }
            };
        }

        final Set<String> expectedTypes = new HashSet<String>();
        expectedTypes.add( type.name() );
        for ( RelationshipType otherType : orAnyOfTheseTypes )
        {
            expectedTypes.add( otherType.name() );
        }

        return new PathEvaluator.Adapter()
        {
            @Override
            public Evaluation evaluate( Path path, BranchState state )
            {
                Relationship lastRelationship = path.lastRelationship();
                if ( lastRelationship == null )
                {
                    return evaluationIfNoMatch;
                }

                return expectedTypes.contains( lastRelationship.getType().name() ) ?
                        evaluationIfMatch : evaluationIfNoMatch;
            }
        };
    }

Replace Generic With Diamond HashSet<String> with HashSet<> in method public lastRelationshipTypeIs(evaluationIfMatch Evaluation, evaluationIfNoMatch Evaluation, type RelationshipType, orAnyOfTheseTypes RelationshipType...) : PathEvaluator from class org.neo4j.graphdb.traversal.Evaluators


    /**
     * An {@link Evaluator} which will return {@code evaluationIfMatch} if {@link Path#endNode()}
     * for a given path is any of {@code nodes}, else {@code evaluationIfNoMatch}.
     *
     * @param evaluationIfMatch   the {@link Evaluation} to return if the {@link Path#endNode()}
     *                            is any of the nodes in {@code nodes}.
     * @param evaluationIfNoMatch the {@link Evaluation} to return if the {@link Path#endNode()}
     *                            doesn't match any of the nodes in {@code nodes}.
     * @param possibleEndNodes    a set of nodes to match to end nodes in paths.
     * @return an {@link Evaluator} which will return {@code evaluationIfMatch} if
     *         {@link Path#endNode()} for a given path is any of {@code nodes},
     *         else {@code evaluationIfNoMatch}.
     */
    @SuppressWarnings( "rawtypes" )
    public static PathEvaluator endNodeIs( final Evaluation evaluationIfMatch, final Evaluation evaluationIfNoMatch,
            Node... possibleEndNodes )
    {
        if ( possibleEndNodes.length == 1 )
        {
            final Node target = possibleEndNodes[0];
            return new PathEvaluator.Adapter()
            {
                @Override
                public Evaluation evaluate( Path path, BranchState state )
                {
                    return target.equals( path.endNode() ) ? evaluationIfMatch : evaluationIfNoMatch;
                }
            };
        }

        final Set<Node> endNodes = new HashSet<>( asList( possibleEndNodes ) );
        return new PathEvaluator.Adapter()
        {
            @Override
            public Evaluation evaluate( Path path, BranchState state )
            {
                return endNodes.contains( path.endNode() ) ? evaluationIfMatch : evaluationIfNoMatch;
            }
        };
    }

    /**
     * An {@link Evaluator} which will return {@code evaluationIfMatch} if {@link Path#endNode()}
     * for a given path is any of {@code nodes}, else {@code evaluationIfNoMatch}.
     *
     * @param evaluationIfMatch   the {@link Evaluation} to return if the {@link Path#endNode()}
     *                            is any of the nodes in {@code nodes}.
     * @param evaluationIfNoMatch the {@link Evaluation} to return if the {@link Path#endNode()}
     *                            doesn't match any of the nodes in {@code nodes}.
     * @param possibleEndNodes    a set of nodes to match to end nodes in paths.
     * @return an {@link Evaluator} which will return {@code evaluationIfMatch} if
     *         {@link Path#endNode()} for a given path is any of {@code nodes},
     *         else {@code evaluationIfNoMatch}.
     */
    @SuppressWarnings( "rawtypes" )
    public static PathEvaluator endNodeIs( final Evaluation evaluationIfMatch, final Evaluation evaluationIfNoMatch,
            Node... possibleEndNodes )
    {
        if ( possibleEndNodes.length == 1 )
        {
            final Node target = possibleEndNodes[0];
            return new PathEvaluator.Adapter()
            {
                @Override
                public Evaluation evaluate( Path path, BranchState state )
                {
                    return target.equals( path.endNode() ) ? evaluationIfMatch : evaluationIfNoMatch;
                }
            };
        }

        final Set<Node> endNodes = new HashSet<Node>( asList( possibleEndNodes ) );
        return new PathEvaluator.Adapter()
        {
            @Override
            public Evaluation evaluate( Path path, BranchState state )
            {
                return endNodes.contains( path.endNode() ) ? evaluationIfMatch : evaluationIfNoMatch;
            }
        };
    }

Replace Generic With Diamond HashSet<Node> with HashSet<> in method public endNodeIs(evaluationIfMatch Evaluation, evaluationIfNoMatch Evaluation, possibleEndNodes Node...) : PathEvaluator from class org.neo4j.graphdb.traversal.Evaluators


            @Override
            public Evaluation evaluate( Path path, BranchState state )
            {
                Set<Node> set = new HashSet<>( fullSet );
                for ( Node node : path.reverseNodes() )
                {
                    if ( set.remove( node ) && set.isEmpty() )
                    {
                        return Evaluation.INCLUDE_AND_CONTINUE;
                    }
                }
                return Evaluation.EXCLUDE_AND_CONTINUE;
            }

                @Override
                public Evaluation evaluate( Path path, BranchState state )
                {
                    Set<Node> set = new HashSet<Node>( fullSet );
                    for ( Node node : path.reverseNodes() )
                    {
                        if ( set.remove( node ) && set.isEmpty() )
                        {
                            return Evaluation.INCLUDE_AND_CONTINUE;
                        }
                    }
                    return Evaluation.EXCLUDE_AND_CONTINUE;
                }

Replace Generic With Diamond HashSet<Node> with HashSet<> in method public evaluate(path Path, state BranchState) : Evaluation from class org.neo4j.graphdb.traversal.Evaluators.includeIfContainsAll.new PathEvaluator.Adapter


    @Test
    public void shouldBeAbleToCancelPopulationJob() throws Exception
    {
        // GIVEN
        createNode( map( name, "Mattias" ), FIRST );
        IndexPopulator populator = mock( IndexPopulator.class );
        FlippableIndexProxy index = mock( FlippableIndexProxy.class );
        IndexStoreView storeView = mock( IndexStoreView.class );
        ControlledStoreScan storeScan = new ControlledStoreScan();
        when( storeView.visitNodes( any( int[].class ), any( int[].class ), Matchers.<Visitor<NodePropertyUpdate,RuntimeException>>any() ) )
                .thenReturn(storeScan );

        final IndexPopulationJob job = newIndexPopulationJob( FIRST, name, populator, index, storeView,
                NullLogProvider.getInstance(), false );

        OtherThreadExecutor<Void> populationJobRunner = cleanup.add( new OtherThreadExecutor<Void>(
                "Population job test runner", null ) );
        Future<Void> runFuture = populationJobRunner
                .executeDontWait( (WorkerCommand<Void,Void>) state -> {
                    job.run();
                    return null;
                } );

        storeScan.latch.awaitStart();
        job.cancel().get();
        storeScan.latch.awaitFinish();

        // WHEN
        runFuture.get();

        // THEN
        verify( populator, times( 1 ) ).close( false );
        verify( index, times( 0 ) ).flip( Matchers.<Callable<Void>>any(), Matchers.<FailedIndexProxyFactory>any() );

        // AND ALSO
        assertDoubleLongEquals( 0, 0, indexUpdatesAndSize( FIRST, name ) );

        // AND ALSO
        assertDoubleLongEquals( 0, 0, indexSample( FIRST, name ) );
    }

    @Test
    public void shouldBeAbleToCancelPopulationJob() throws Exception
    {
        // GIVEN
        createNode( map( name, "Mattias" ), FIRST );
        IndexPopulator populator = mock( IndexPopulator.class );
        FlippableIndexProxy index = mock( FlippableIndexProxy.class );
        IndexStoreView storeView = mock( IndexStoreView.class );
        ControlledStoreScan storeScan = new ControlledStoreScan();
        when( storeView.visitNodesWithPropertyAndLabel( any( IndexDescriptor.class ),
                Matchers.<Visitor<NodePropertyUpdate, RuntimeException>>any() ) ).thenReturn( storeScan );

        final IndexPopulationJob job = newIndexPopulationJob( FIRST, name, populator, index, storeView,
                NullLogProvider.getInstance(), false );

        OtherThreadExecutor<Void> populationJobRunner = cleanup.add( new OtherThreadExecutor<Void>(
                "Population job test runner", null ) );
        Future<Void> runFuture = populationJobRunner.executeDontWait( new WorkerCommand<Void, Void>()
        {
            @Override
            public Void doWork( Void state )
            {
                job.run();
                return null;
            }
        } );

        storeScan.latch.awaitStart();
        job.cancel().get();
        storeScan.latch.awaitFinish();

        // WHEN
        runFuture.get();

        // THEN
        verify( populator, times( 1 ) ).close( false );
        verify( index, times( 0 ) ).flip( Matchers.<Callable<Void>>any(), Matchers.<FailedIndexProxyFactory>any() );

        // AND ALSO
        assertDoubleLongEquals( 0, 0, indexUpdatesAndSize( FIRST, name ) );

        // AND ALSO
        assertDoubleLongEquals( 0, 0, indexSample( FIRST, name ) );
    }

Replace Anonymous With Lambda org.neo4j.kernel.impl.api.index.IndexPopulationJobTest.shouldBeAbleToCancelPopulationJob.runFuture.executeDontWait.new WorkerCommand<Void,Void> with state -> {job.run(); in method public shouldBeAbleToCancelPopulationJob() : void from class org.neo4j.kernel.impl.api.index.IndexPopulationJobTest


    private Answer<Void> waitForLatch( final CountDownLatch latch )
    {
        return invocationOnMock -> {
            latch.await();
            return null;
        };
    }

    private Answer<Void> waitForLatch( final CountDownLatch latch )
    {
        return new Answer<Void>()
        {
            @Override
            public Void answer( InvocationOnMock invocationOnMock ) throws Throwable
            {
                latch.await();
                return null;
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.kernel.impl.api.index.IndexingServiceTest.waitForLatch.new Answer<Void> with invocationOnMock -> {latch.await(); in method private waitForLatch(latch CountDownLatch) : Answer<Void> from class org.neo4j.kernel.impl.api.index.IndexingServiceTest


    private Answer<ResourceIterator<File>> newResourceIterator( final File theFile )
    {
        return invocationOnMock -> asResourceIterator(iterator( theFile ));
    }

    private Answer<ResourceIterator<File>> newResourceIterator( final File theFile )
    {
        return new Answer<ResourceIterator<File>>(){

            @Override
            public ResourceIterator<File> answer( InvocationOnMock invocationOnMock ) throws Throwable
            {
                return asResourceIterator(iterator( theFile ));
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.kernel.impl.api.index.IndexingServiceTest.newResourceIterator.new Answer<ResourceIterator<File>> with invocationOnMock -> asResourceIterator(iterator(theFile)) in method private newResourceIterator(theFile File) : Answer<ResourceIterator<File>> from class org.neo4j.kernel.impl.api.index.IndexingServiceTest


    private Answer nodeUpdatesAnswer( NodePropertyUpdate... updates )
    {
        return invocation -> {
            Collection<NodePropertyUpdate> target = (Collection<NodePropertyUpdate>) invocation.getArguments()[2];
            target.addAll( asList( updates ) );
            return null;
        };
    }

    private Answer nodeUpdatesAnswer( NodePropertyUpdate... updates )
    {
        return new Answer<Void>()
        {
            @Override
            public Void answer( InvocationOnMock invocation ) throws Throwable
            {
                Collection<NodePropertyUpdate> target = (Collection<NodePropertyUpdate>) invocation.getArguments()[2];
                target.addAll( asList( updates ) );
                return null;
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.kernel.impl.api.index.IndexingServiceTest.nodeUpdatesAnswer.new Answer<Void> with invocation -> {Collection<NodePropertyUpdate> target=(Collection<NodePropertyUpdate>)invocation.getArguments()[2]; in method private nodeUpdatesAnswer(updates NodePropertyUpdate...) : Answer from class org.neo4j.kernel.impl.api.index.IndexingServiceTest


    public IndexProxy createPopulatingIndexProxy( final long ruleId,
                                                  final IndexDescriptor descriptor,
                                                  final SchemaIndexProvider.Descriptor providerDescriptor,
                                                  final boolean constraint,
                                                  final IndexingService.Monitor monitor,
                                                  final IndexPopulationJob populationJob ) throws IOException
    {
        final FlippableIndexProxy flipper = new FlippableIndexProxy();

        // TODO: This is here because there is a circular dependency from PopulatingIndexProxy to FlippableIndexProxy
        final String indexUserDescription = indexUserDescription( descriptor, providerDescriptor );
        final IndexConfiguration config = IndexConfiguration.of( constraint );
        IndexPopulator populator = populatorFromProvider( providerDescriptor, ruleId, descriptor, config,
                samplingConfig );

        FailedIndexProxyFactory failureDelegateFactory = new FailedPopulatingIndexProxyFactory(
                descriptor,
                config,
                providerDescriptor,
                populator,
                indexUserDescription,
                new IndexCountsRemover( storeView, descriptor ),
                logProvider
        );

        PopulatingIndexProxy populatingIndex =
                new PopulatingIndexProxy( descriptor, config, providerDescriptor, populationJob );

        populationJob.addPopulator( populator, descriptor, config, providerDescriptor, indexUserDescription,
                flipper, failureDelegateFactory );

        flipper.flipTo( populatingIndex );

        // Prepare for flipping to online mode
        flipper.setFlipTarget( () -> {
            try
            {
                monitor.populationCompleteOn( descriptor );
                OnlineIndexProxy onlineProxy = new OnlineIndexProxy(
                        descriptor, config, onlineAccessorFromProvider( providerDescriptor, ruleId,
                        config, samplingConfig ), storeView, providerDescriptor
                );
                if ( constraint )
                {
                    return new TentativeConstraintIndexProxy( flipper, onlineProxy );
                }
                return onlineProxy;
            }
            catch ( IOException e )
            {
                return createFailedIndexProxy( ruleId, descriptor, providerDescriptor, constraint, failure( e ) );
            }
        } );

        return new ContractCheckingIndexProxy( flipper, false );
    }

    public IndexProxy createPopulatingIndexProxy( final long ruleId,
                                                  final IndexDescriptor descriptor,
                                                  final SchemaIndexProvider.Descriptor providerDescriptor,
                                                  final boolean constraint,
                                                  final IndexingService.Monitor monitor ) throws IOException
    {
        final FlippableIndexProxy flipper = new FlippableIndexProxy();

        // TODO: This is here because there is a circular dependency from PopulatingIndexProxy to FlippableIndexProxy
        final String indexUserDescription = indexUserDescription( descriptor, providerDescriptor );
        final IndexConfiguration config = IndexConfiguration.of( constraint );
        IndexPopulator populator = populatorFromProvider( providerDescriptor, ruleId, descriptor, config,
                samplingConfig );

        FailedIndexProxyFactory failureDelegateFactory = new FailedPopulatingIndexProxyFactory(
                descriptor,
                config,
                providerDescriptor,
                populator,
                indexUserDescription,
                IndexCountsRemover.Factory.create( storeView, descriptor ),
                logProvider
        );

        PopulatingIndexProxy populatingIndex =
                new PopulatingIndexProxy( scheduler, descriptor, config, failureDelegateFactory, populator, flipper,
                        storeView, logProvider, indexUserDescription, providerDescriptor, monitor,
                        schemaStateChangeCallback );
        flipper.flipTo( populatingIndex );

        // Prepare for flipping to online mode
        flipper.setFlipTarget( new IndexProxyFactory()
        {
            @Override
            public IndexProxy create()
            {
                try
                {
                    monitor.populationCompleteOn( descriptor );
                    OnlineIndexProxy onlineProxy = new OnlineIndexProxy(
                            descriptor, config, onlineAccessorFromProvider( providerDescriptor, ruleId,
                            config, samplingConfig ), storeView, providerDescriptor
                    );
                    if ( constraint )
                    {
                        return new TentativeConstraintIndexProxy( flipper, onlineProxy );
                    }
                    return onlineProxy;
                }
                catch ( IOException e )
                {
                    return createFailedIndexProxy( ruleId, descriptor, providerDescriptor, constraint, failure( e ) );
                }
            }
        } );

        return new ContractCheckingIndexProxy( flipper, false );
    }

Replace Anonymous With Lambda org.neo4j.kernel.impl.api.index.IndexProxySetup.createPopulatingIndexProxy.setFlipTarget.new IndexProxyFactory with () -> {trymonitor.populationCompleteOn(descriptor); in method public createPopulatingIndexProxy(ruleId long, descriptor IndexDescriptor, providerDescriptor SchemaIndexProvider.Descriptor, constraint boolean, monitor IndexingService.Monitor, populationJob IndexPopulationJob) : IndexProxy from class org.neo4j.kernel.impl.api.index.IndexProxyCreator


    private static File[] txLogsIn( File dir )
    {
        File[] logs = dir.listFiles( LogFiles.FILENAME_FILTER );
        Arrays.sort( logs, ( f1, f2 ) -> {
            long f1Version = PhysicalLogFiles.getLogVersion( f1 );
            long f2Version = PhysicalLogFiles.getLogVersion( f2 );
            return Long.compare( f1Version, f2Version );
        } );
        return logs;
    }

    private static File[] txLogsIn( File dir )
    {
        File[] logs = dir.listFiles( LogFiles.FILENAME_FILTER );
        Arrays.sort( logs, new Comparator<File>()
        {
            @Override
            public int compare( File f1, File f2 )
            {
                long f1Version = PhysicalLogFiles.getLogVersion( f1 );
                long f2Version = PhysicalLogFiles.getLogVersion( f2 );
                return Long.compare( f1Version, f2Version );
            }
        } );
        return logs;
    }

Replace Anonymous With Lambda org.neo4j.tools.txlog.CheckTxLogs.txLogsIn.sort.new Comparator<File> with (f1, f2) -> {long f1Version=PhysicalLogFiles.getLogVersion(f1); in method private txLogsIn(dir File) : File[] from class org.neo4j.tools.txlog.CheckTxLogs


    private static Map<IdType,Long> getHighIds( GraphDatabaseAPI db )
    {
        final Map<IdType,Long> highIds = new HashMap<>();
        NeoStores neoStores = db.getDependencyResolver().resolveDependency(
                DataSourceManager.class ).getDataSource().getNeoStores();
        neoStores.visitStore( store -> {
            highIds.put( store.getIdType(), store.getHighId() );
            return true;
        } );
        return highIds;
    }

    private Map<IdType,Long> getHighIds( GraphDatabaseAPI db )
    {
        final Map<IdType,Long> highIds = new HashMap<>();
        NeoStores neoStores = db.getDependencyResolver().resolveDependency(
                DataSourceManager.class ).getDataSource().getNeoStores();
        neoStores.visitStore( new Visitor<CommonAbstractStore,RuntimeException>()
        {
            @Override
            public boolean visit( CommonAbstractStore store ) throws RuntimeException
            {
                highIds.put( store.getIdType(), store.getHighId() );
                return true;
            }
        } );
        return highIds;
    }

Replace Anonymous With Lambda org.neo4j.kernel.impl.core.TestCrashWithRebuildSlow.getHighIds.visitStore.new Visitor<CommonAbstractStore,RuntimeException> with store -> {highIds.put(store.getIdType(),store.getHighId()); in method private getHighIds(db GraphDatabaseAPI) : Map<IdType,Long> from class org.neo4j.kernel.impl.core.TestCrashWithRebuildSlow


    public static Function<Node,Node> addLabel( Label label )
    {
        return node -> {
            node.addLabel( label );
            return node;
        };
    }

    public static AlgebraicFunction<Node, Node> addLabel( final Label label )
    {
        return new AlgebraicFunction<Node, Node>()
        {
            @Override
            public Node apply( Node node )
            {
                node.addLabel( label );
                return node;
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.test.DatabaseFunctions.addLabel.new AlgebraicFunction<Node,Node> with node -> {node.addLabel(label); in method public addLabel(label Label) : Function<Node,Node> from class org.neo4j.test.DatabaseFunctions


    public static Function<Node,Node> setProperty( String propertyKey, Object value )
    {
        return node -> {
            node.setProperty( propertyKey, value );
            return node;
        };
    }

    public static AlgebraicFunction<Node, Node> setProperty( final String propertyKey, final Object value )
    {
        return new AlgebraicFunction<Node, Node>()
        {
            @Override
            public Node apply( Node node )
            {
                node.setProperty( propertyKey, value );
                return node;
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.test.DatabaseFunctions.setProperty.new AlgebraicFunction<Node,Node> with node -> {node.setProperty(propertyKey,value); in method public setProperty(propertyKey String, value Object) : Function<Node,Node> from class org.neo4j.test.DatabaseFunctions


/**
     * This mechanism can be used as an argument to {@link #view(Function)} to view a set of config options that share a common base config key as a group.
     * This specific version handles multiple groups, so the common base key should be followed by a number denoting the group, followed by the group config
     * values, eg:
     *
     * {@code <base name>.<group key>.<config key>}
     *
     * The config of each group can then be accessed as if the {@code config key} in the pattern above was the entire config key. For example, given the
     * following configuration:
     *
     *

     *     dbms.books.0.name=Hansel & Gretel
     *     dbms.books.0.author=JJ Abrams
     *     dbms.books.1.name=NKJV
     *     dbms.books.1.author=Jesus
     *

     *
     * We can then access these config values as groups:
     *
     *

     * {@code
     *     Setting<String> bookName = setting("name", STRING); // note that the key here is only 'name'
     *
     *     ConfigView firstBook = config.view( groups("dbms.books") ).get(0);
     *
     *     assert firstBook.get(bookName).equals("Hansel & Gretel");
     * }
     *

     *
     * @param baseName the base name for the groups, this will be the first part of the config key, followed by a grouping number, followed by the group
     *                 config options
     * @return a list of grouped config options
     */
    public static Function<ConfigValues,List<ConfigView>> groups( String baseName )
    {
        Pattern pattern = Pattern.compile( Pattern.quote( baseName ) + "\\.(\\d+)\\.(.+)" );

        return ( values ) -> {
            Map<String,Map<String,String>> groups = new HashMap<>();
            for ( Pair<String,String> entry : values.rawConfiguration() )
            {
                Matcher matcher = pattern.matcher( entry.first() );

                if( matcher.matches() )
                {
                    String index = matcher.group( 1 );
                    String configName = matcher.group( 2 );
                    String value = entry.other();

                    Map<String,String> groupConfig = groups.get( index );
                    if ( groupConfig == null )
                    {
                        groupConfig = new HashMap<>();
                        groups.put( index, groupConfig );
                    }
                    groupConfig.put( configName, value );
                }
            }

            Function<Map<String,String>,ConfigView> mapper = m -> new ConfigView()
            {
                @Override
                public <T> T get( Setting<T> setting )
                {
                    return setting.apply( m::get );
                }
            };
            return groups.values().stream()
                    .map( mapper )
                    .collect( toList() );
        };
    }

/**
     * This mechanism can be used as an argument to {@link #view(Function)} to view a set of config options that share a common base config key as a group.
     * This specific version handles multiple groups, so the common base key should be followed by a number denoting the group, followed by the group config
     * values, eg:
     *
     * {@code <base name>.<group key>.<config key>}
     *
     * The config of each group can then be accessed as if the {@code config key} in the pattern above was the entire config key. For example, given the
     * following configuration:
     *
     *

     *     dbms.books.0.name=Hansel & Gretel
     *     dbms.books.0.author=JJ Abrams
     *     dbms.books.1.name=NKJV
     *     dbms.books.1.author=Jesus
     *

     *
     * We can then access these config values as groups:
     *
     *

     * {@code
     *     Setting<String> bookName = setting("name", STRING); // note that the key here is only 'name'
     *
     *     ConfigView firstBook = config.view( groups("dbms.books") ).get(0);
     *
     *     assert firstBook.get(bookName).equals("Hansel & Gretel");
     * }
     *

     *
     * @param baseName the base name for the groups, this will be the first part of the config key, followed by a grouping number, followed by the group
     *                 config options
     * @return a list of grouped config options
     */
    public static Function<ConfigValues,List<ConfigView>> groups( String baseName )
    {
        Pattern pattern = Pattern.compile( Pattern.quote( baseName ) + "\\.(\\d+)\\.(.+)" );

        return ( values ) -> {
            Map<String,Map<String,String>> groups = new HashMap<>();
            for ( Pair<String,String> entry : values.rawConfiguration() )
            {
                Matcher matcher = pattern.matcher( entry.first() );

                if( matcher.matches() )
                {
                    String index = matcher.group( 1 );
                    String configName = matcher.group( 2 );
                    String value = entry.other();

                    Map<String,String> groupConfig = groups.get( index );
                    if ( groupConfig == null )
                    {
                        groupConfig = new HashMap<>();
                        groups.put( index, groupConfig );
                    }
                    groupConfig.put( configName, value );
                }
            }

            return groups.values().stream()
                    .map( m -> new ConfigView()
                    {
                        @Override
                        public <T> T get( Setting<T> setting )
                        {
                            return setting.apply( m::get );
                        }
                    })
                    .collect( toList() );
        };
    }

Replace Anonymous With Lambda org.neo4j.kernel.configuration.Config.groups.collect.map.new ConfigView with m -> new ConfigView(){ in method public groups(baseName String) : Function<ConfigValues,List<ConfigView>> from class org.neo4j.kernel.configuration.Config


    public Function<NodeRecord,Check<NodeRecord,ConsistencyReport.NodeConsistencyReport>> forNodes(
            final ConsistencyReporter reporter )
    {
        return node -> {
            PrimitiveIntSet keys = null;
            for ( long labelId : NodeLabelReader.getListOfLabels( node, storeAccess.getNodeDynamicLabelStore() ) )
            {
                // labelId _is_ actually an int. A technical detail in the store format has these come in a long[]
                int[] propertyKeys = nodes.get( Utils.safeCastLongToInt( labelId ) );
                if ( propertyKeys != null )
                {
                    if ( keys == null )
                    {
                        keys = Primitive.intSet( 16 );
                    }
                    for ( int key : propertyKeys )
                    {
                        keys.add( key );
                    }
                }
            }
            return keys != null
                    ? new RealCheck<>( node, ConsistencyReport.NodeConsistencyReport.class, reporter,
                            RecordType.NODE, keys )
                    : MandatoryProperties.<NodeRecord,ConsistencyReport.NodeConsistencyReport>noCheck();
        };
    }

    public Function<NodeRecord,Check<NodeRecord,ConsistencyReport.NodeConsistencyReport>> forNodes(
            final ConsistencyReporter reporter )
    {
        return new Function<NodeRecord,Check<NodeRecord,ConsistencyReport.NodeConsistencyReport>>()
        {
            @Override
            public Check<NodeRecord,ConsistencyReport.NodeConsistencyReport> apply( NodeRecord node )
            {
                PrimitiveIntSet keys = null;
                for ( long labelId : NodeLabelReader.getListOfLabels( node, storeAccess.getNodeDynamicLabelStore() ) )
                {
                    // labelId _is_ actually an int. A technical detail in the store format has these come in a long[]
                    int[] propertyKeys = nodes.get( Utils.safeCastLongToInt( labelId ) );
                    if ( propertyKeys != null )
                    {
                        if ( keys == null )
                        {
                            keys = Primitive.intSet( 16 );
                        }
                        for ( int key : propertyKeys )
                        {
                            keys.add( key );
                        }
                    }
                }
                return keys != null
                        ? new RealCheck<>( node, ConsistencyReport.NodeConsistencyReport.class, reporter,
                                RecordType.NODE, keys )
                        : MandatoryProperties.<NodeRecord,ConsistencyReport.NodeConsistencyReport>noCheck();
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.consistency.checking.full.MandatoryProperties.forNodes.new Function<NodeRecord,Check<NodeRecord,ConsistencyReport.NodeConsistencyReport>> with node -> {PrimitiveIntSet keys=null; in method public forNodes(reporter ConsistencyReporter) : Function<NodeRecord,Check<NodeRecord,ConsistencyReport.NodeConsistencyReport>> from class org.neo4j.consistency.checking.full.MandatoryProperties


    public Function<RelationshipRecord,Check<RelationshipRecord,ConsistencyReport.RelationshipConsistencyReport>>
            forRelationships( final ConsistencyReporter reporter )
    {
        return relationship -> {
            int[] propertyKeys = relationships.get( relationship.getType() );
            if ( propertyKeys != null )
            {
                PrimitiveIntSet keys = Primitive.intSet( propertyKeys.length );
                for ( int key : propertyKeys )
                {
                    keys.add( key );
                }
                return new RealCheck<>( relationship, ConsistencyReport.RelationshipConsistencyReport.class,
                        reporter, RecordType.RELATIONSHIP, keys );
            }
            return noCheck();
        };
    }

    public Function<RelationshipRecord,Check<RelationshipRecord,ConsistencyReport.RelationshipConsistencyReport>>
            forRelationships( final ConsistencyReporter reporter )
    {
        return new Function<RelationshipRecord,Check<RelationshipRecord,ConsistencyReport.RelationshipConsistencyReport>>()
        {
            @Override
            public Check<RelationshipRecord,ConsistencyReport.RelationshipConsistencyReport> apply( RelationshipRecord relationship )
            {
                int[] propertyKeys = relationships.get( relationship.getType() );
                if ( propertyKeys != null )
                {
                    PrimitiveIntSet keys = Primitive.intSet( propertyKeys.length );
                    for ( int key : propertyKeys )
                    {
                        keys.add( key );
                    }
                    return new RealCheck<>( relationship, ConsistencyReport.RelationshipConsistencyReport.class,
                            reporter, RecordType.RELATIONSHIP, keys );
                }
                return noCheck();
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.consistency.checking.full.MandatoryProperties.forRelationships.new Function<RelationshipRecord,Check<RelationshipRecord,ConsistencyReport.RelationshipConsistencyReport>> with relationship -> {int[] propertyKeys=relationships.get(relationship.getType()); in method public forRelationships(reporter ConsistencyReporter) : Function<RelationshipRecord,Check<RelationshipRecord,ConsistencyReport.RelationshipConsistencyReport>> from class org.neo4j.consistency.checking.full.MandatoryProperties


    public static <From, To> Function<From,To> withDefaults( final Function<From,To> defaults, final Function<From,
            To> f )
    {
        return from -> {
            To to = f.apply( from );

            if ( to == null )
            {
                return defaults.apply( from );
            }
            else
            {
                return to;
            }
        };
    }

    public static <From, To> Function<From,To> withDefaults( final Function<From,To> defaults, final Function<From,
            To> f )
    {
        return new Function<From,To>()
        {
            @Override
            public To apply( From from )
            {
                To to = f.apply( from );

                if ( to == null )
                {
                    return defaults.apply( from );
                }
                else
                {
                    return to;
                }
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.function.Functions.withDefaults.new Function<From,To> with from -> {To to=f.apply(from); in method public withDefaults(defaults Function<From,To>, f Function<From,To>) : Function<From,To> from class org.neo4j.function.Functions


    public static <From, To> Function<From,To> nullFunction()
    {
        return from -> {
            return null; // Always return null
        };
    }

    public static <From, To> Function<From,To> nullFunction()
    {
        return new Function<From,To>()
        {
            @Override
            public To apply( From from )
            {
                return null; // Always return null
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.function.Functions.nullFunction.new Function<From,To> with from -> {return null; in method public nullFunction() : Function<From,To> from class org.neo4j.function.Functions


    public static <T> Function<T,Void> fromConsumer( final Consumer<T> consumer )
    {
        return t -> {
            consumer.accept( t );
            return null;
        };
    }

    public static <T> Function<T,Void> fromConsumer( final Consumer<T> consumer )
    {
        return new Function<T,Void>()
        {
            @Override
            public Void apply( T t )
            {
                consumer.accept( t );
                return null;
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.function.Functions.fromConsumer.new Function<T,Void> with t -> {consumer.accept(t); in method public fromConsumer(consumer Consumer<T>) : Function<T,Void> from class org.neo4j.function.Functions


    private static <T> Function<Function<String, String>, String> inheritedDefault( final Function<Function<String,
            String>, String> lookup, final Setting<T> inheritedSetting )
    {
        return settings -> {
            String value = lookup.apply( settings );
            if ( value == null )
            {
                value = ((SettingHelper<T>) inheritedSetting).defaultLookup( settings );
            }
            return value;
        };
    }

    private static <T> Function<Function<String, String>, String> inheritedDefault( final Function<Function<String,
            String>, String> lookup, final Setting<T> inheritedSetting )
    {
        return new Function<Function<String, String>, String>()
        {
            @Override
            public String apply( Function<String, String> settings )
            {
                String value = lookup.apply( settings );
                if ( value == null )
                {
                    value = ((SettingHelper<T>) inheritedSetting).defaultLookup( settings );
                }
                return value;
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.helpers.Settings.inheritedDefault.new Function<Function<String,String>,String> with settings -> {String value=lookup.apply(settings); in method private inheritedDefault(lookup Function<Function<String,String>,String>, inheritedSetting Setting<T>) : Function<Function<String,String>,String> from class org.neo4j.helpers.Settings


    public void execute( final Consumer<Transaction> txConsumer )
    {
        execute( transaction -> {
            txConsumer.accept( transaction );
            return null;
        } );
    }

    public void execute( final Consumer<Transaction> txConsumer )
    {
        execute( new Function<Transaction, Object>()
        {
            @Override
            public Object apply( Transaction transaction )
            {
                txConsumer.accept( transaction );
                return null;
            }
        } );
    }

Replace Anonymous With Lambda org.neo4j.helpers.TransactionTemplate.execute.execute.new Function<Transaction,Object> with transaction -> {txConsumer.accept(transaction); in method public execute(txConsumer Consumer<Transaction>) : void from class org.neo4j.helpers.TransactionTemplate


    /**
     * Extract a named parameter from the query of a URI. If a parameter is set but no value defined,
     * then "true" is returned
     *
     * @param name of the parameter
     * @return value of named parameter or null if missing
     */
    public static Function<URI, String> parameter( final String name )
    {
        return uri -> {
            if ( uri == null )
            {
                return null;
            }

            String query = uri.getQuery();
            if (query != null)
            {
                for ( String param : query.split( "&" ) )
                {
                    String[] keyValue = param.split( "=" );

                    if ( keyValue[0].equalsIgnoreCase( name ) )
                    {
                        if ( keyValue.length == 2 )
                        {
                            return keyValue[1];
                        }
                        else
                        {
                            return "true";
                        }
                    }
                }
            }
            return null;
        };
    }

    /**
     * Extract a named parameter from the query of a URI. If a parameter is set but no value defined,
     * then "true" is returned
     *
     * @param name of the parameter
     * @return value of named parameter or null if missing
     */
    public static Function<URI, String> parameter( final String name )
    {
        return new Function<URI, String>()
        {
            @Override
            public String apply( URI uri )
            {
                if ( uri == null )
                {
                    return null;
                }

                String query = uri.getQuery();
                if (query != null)
                {
                    for ( String param : query.split( "&" ) )
                    {
                        String[] keyValue = param.split( "=" );

                        if ( keyValue[0].equalsIgnoreCase( name ) )
                        {
                            if ( keyValue.length == 2 )
                            {
                                return keyValue[1];
                            }
                            else
                            {
                                return "true";
                            }
                        }
                    }
                }
                return null;
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.helpers.Uris.parameter.new Function<URI,String> with uri -> {if(uri == null){return null; in method public parameter(name String) : Function<URI,String> from class org.neo4j.helpers.Uris


    public static <T extends CloneableInPublic> Iterable<T> cloned( Iterable<T> items, final Class<T> itemClass )
    {
        return Iterables.map( from -> {
            return itemClass.cast( from.clone() );
        }, items );
    }

    public static <T extends CloneableInPublic> Iterable<T> cloned( Iterable<T> items, final Class<T> itemClass )
    {
        return Iterables.map( new Function<T,T>()
        {
            @Override
            public T apply( T from )
            {
                return itemClass.cast( from.clone() );
            }
        }, items );
    }

Replace Anonymous With Lambda org.neo4j.helpers.collection.IteratorUtil.cloned.map.new Function<T,T> with from -> {return itemClass.cast(from.clone()); in method public cloned(items Iterable<T>, itemClass Class<T>) : Iterable<T> from class org.neo4j.helpers.collection.IteratorUtil


    public Config()
    {
        this( new HashMap<>(), Collections.<Class<?>>emptyList() );
    }

    public Config()
    {
        this( new HashMap<String, String>(), Collections.<Class<?>>emptyList() );
    }

Replace Generic With Diamond HashMap<String,String> with HashMap<> in method public Config() from class org.neo4j.kernel.configuration.Config


    private static Function<Function<String, String>, String> withDefault( final String defaultValue,
                                                                           final Function<Function<String, String>,
                                                                                String> lookup )
    {
        return settings -> {
            String value = lookup.apply( settings );
            if ( value == null )
            {
                return defaultValue;
            }
            else
            {
                return value;
            }
        };
    }

    private static Function<Function<String, String>, String> withDefault( final String defaultValue,
                                                                           final Function<Function<String, String>,
                                                                                String> lookup )
    {
        return new Function<Function<String, String>, String>()
        {
            @Override
            public String apply( Function<String, String> settings )
            {
                String value = lookup.apply( settings );
                if ( value == null )
                {
                    return defaultValue;
                }
                else
                {
                    return value;
                }
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.kernel.configuration.Settings.withDefault.new Function<Function<String,String>,String> with settings -> {String value=lookup.apply(settings); in method private withDefault(defaultValue String, lookup Function<Function<String,String>,String>) : Function<Function<String,String>,String> from class org.neo4j.kernel.configuration.Settings


    private static Function<Function<String, String>, String> mandatory( final Function<Function<String, String>,
            String> lookup )
    {
        return settings -> {
            String value = lookup.apply( settings );
            if ( value == null )
            {
                throw new IllegalArgumentException( "mandatory setting is missing" );
            }
            return value;
        };
    }

    private static Function<Function<String, String>, String> mandatory( final Function<Function<String, String>,
            String> lookup )
    {
        return new Function<Function<String, String>, String>()
        {
            @Override
            public String apply( Function<String, String> settings )
            {
                String value = lookup.apply( settings );
                if ( value == null )
                {
                    throw new IllegalArgumentException( "mandatory setting is missing" );
                }
                return value;
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.kernel.configuration.Settings.mandatory.new Function<Function<String,String>,String> with settings -> {String value=lookup.apply(settings); in method private mandatory(lookup Function<Function<String,String>,String>) : Function<Function<String,String>,String> from class org.neo4j.kernel.configuration.Settings


    private Function<Map<Integer, Set<Long>>, Iterator<Set<Long>>> typeFilter( final int[] types )
    {
        return relationshipsByType -> new PrefetchingIterator<Set<Long>>()
        {
            private final PrimitiveIntIterator iterTypes = iterator( types );

            @Override
            protected Set<Long> fetchNextOrNull()
            {
                while ( iterTypes.hasNext() )
                {
                    Set<Long> relsByType = relationshipsByType.get( iterTypes.next() );
                    if ( relsByType != null )
                    {
                        return relsByType;
                    }
                }
                return null;
            }
        };
    }

    private Function<Map<Integer, Set<Long>>, Iterator<Set<Long>>> typeFilter( final int[] types )
    {
        return new Function<Map<Integer, Set<Long>>, Iterator<Set<Long>>>()
        {
            @Override
            public Iterator<Set<Long>> apply( final Map<Integer, Set<Long>> relationshipsByType )
            {
                return new PrefetchingIterator<Set<Long>>()
                {
                    private final PrimitiveIntIterator iterTypes = iterator( types );

                    @Override
                    protected Set<Long> fetchNextOrNull()
                    {
                        while ( iterTypes.hasNext() )
                        {
                            Set<Long> relsByType = relationshipsByType.get( iterTypes.next() );
                            if ( relsByType != null )
                            {
                                return relsByType;
                            }
                        }
                        return null;
                    }
                };
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.kernel.impl.api.state.RelationshipChangesForNode.typeFilter.new Function<Map<Integer,Set<Long>>,Iterator<Set<Long>>> with relationshipsByType -> new PrefetchingIterator<Set<Long>>(){ in method private typeFilter(types int[]) : Function<Map<Integer,Set<Long>>,Iterator<Set<Long>>> from class org.neo4j.kernel.impl.api.state.RelationshipChangesForNode


    @Override
    public Iterable<IndexDescriptor> constraintIndexesCreatedInTx()
    {
        if ( createdConstraintIndexesByConstraint != null && !createdConstraintIndexesByConstraint.isEmpty() )
        {

            return map( constraint -> {
                return new IndexDescriptor( constraint.label(), constraint.propertyKey() );
            }, createdConstraintIndexesByConstraint.keySet() );
        }
        return Iterables.empty();
    }

    @Override
    public Iterable<IndexDescriptor> constraintIndexesCreatedInTx()
    {
        if ( createdConstraintIndexesByConstraint != null && !createdConstraintIndexesByConstraint.isEmpty() )
        {

            return map( new Function<UniquenessConstraint, IndexDescriptor>()
            {
                @Override
                public IndexDescriptor apply( UniquenessConstraint constraint )
                {
                    return new IndexDescriptor( constraint.label(), constraint.propertyKey() );
                }
            }, createdConstraintIndexesByConstraint.keySet() );
        }
        return Iterables.empty();
    }

Replace Anonymous With Lambda org.neo4j.kernel.impl.api.state.TxState.constraintIndexesCreatedInTx.map.new Function<UniquenessConstraint,IndexDescriptor> with constraint -> {return new IndexDescriptor(constraint.label(),constraint.propertyKey()); in method public constraintIndexesCreatedInTx() : Iterable<IndexDescriptor> from class org.neo4j.kernel.impl.api.state.TxState


    private void addDefinitions( List<IndexDefinition> definitions, final ReadOperations statement,
                                 Iterator<IndexDescriptor> indexes, final boolean constraintIndex )
    {
        addToCollection( map( (Function<IndexDescriptor,IndexDefinition>) rule -> {
            try
            {
                Label label = label( statement.labelGetName( rule.getLabelId() ) );
                String propertyKey = statement.propertyKeyGetName( rule.getPropertyKeyId() );
                return new IndexDefinitionImpl( actions, label, propertyKey, constraintIndex );
            }
            catch ( LabelNotFoundKernelException | PropertyKeyIdNotFoundKernelException e )
            {
                throw new RuntimeException( e );
            }
        }, indexes ), definitions );
    }

    private void addDefinitions( List<IndexDefinition> definitions, final ReadOperations statement,
                                 Iterator<IndexDescriptor> indexes, final boolean constraintIndex )
    {
        addToCollection( map( new Function<IndexDescriptor,IndexDefinition>()
        {
            @Override
            public IndexDefinition apply( IndexDescriptor rule )
            {
                try
                {
                    Label label = label( statement.labelGetName( rule.getLabelId() ) );
                    String propertyKey = statement.propertyKeyGetName( rule.getPropertyKeyId() );
                    return new IndexDefinitionImpl( actions, label, propertyKey, constraintIndex );
                }
                catch ( LabelNotFoundKernelException | PropertyKeyIdNotFoundKernelException e )
                {
                    throw new RuntimeException( e );
                }
            }
        }, indexes ), definitions );
    }

Replace Anonymous With Lambda org.neo4j.kernel.impl.coreapi.schema.SchemaImpl.addDefinitions.addToCollection.map.new Function<IndexDescriptor,IndexDefinition> with rule -> {tryLabel label=label(statement.labelGetName(rule.getLabelId())); in method private addDefinitions(definitions List<IndexDefinition>, statement ReadOperations, indexes Iterator<IndexDescriptor>, constraintIndex boolean) : void from class org.neo4j.kernel.impl.coreapi.schema.SchemaImpl


    public static <T> Function<String,T> mandatory()
    {
        return key -> {
            throw new IllegalArgumentException( "Missing argument '" + key + "'" );
        };
    }

    public static <T> Function<String,T> mandatory()
    {
        return new Function<String,T>()
        {
            @Override
            public T apply( String key )
            {
                throw new IllegalArgumentException( "Missing argument '" + key + "'" );
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.kernel.impl.util.Converters.mandatory.new Function<String,T> with key -> {throw new IllegalArgumentException("Missing argument '" + key + "'"); in method public mandatory() : Function<String,T> from class org.neo4j.kernel.impl.util.Converters


    public static Function<String,File[]> regexFiles( final boolean cleverNumberRegexSort )
    {
        return name -> {
            Comparator<File> sorting = cleverNumberRegexSort ? BY_FILE_NAME_WITH_CLEVER_NUMBERS : BY_FILE_NAME;
            List<File> files = Validators.matchingFiles( new File( name ) );
            Collections.sort( files, sorting );
            return files.toArray( new File[files.size()] );
        };
    }

    public static Function<String,File[]> regexFiles( final boolean cleverNumberRegexSort )
    {
        return new Function<String,File[]>()
        {
            @Override
            public File[] apply( String name ) throws RuntimeException
            {
                Comparator<File> sorting = cleverNumberRegexSort ? BY_FILE_NAME_WITH_CLEVER_NUMBERS : BY_FILE_NAME;
                List<File> files = Validators.matchingFiles( new File( name ) );
                Collections.sort( files, sorting );
                return files.toArray( new File[files.size()] );
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.kernel.impl.util.Converters.regexFiles.new Function<String,File[]> with name -> {Comparator<File> sorting=cleverNumberRegexSort ? BY_FILE_NAME_WITH_CLEVER_NUMBERS : BY_FILE_NAME; in method public regexFiles(cleverNumberRegexSort boolean) : Function<String,File[]> from class org.neo4j.kernel.impl.util.Converters


    public static Function<String,File[]> toFiles( final String delimiter,
            final Function<String,File[]> eachFileConverter )
    {
        return from -> {
            if ( from == null )
            {
                return new File[0];
            }

            String[] names = from.split( delimiter );
            List<File> files = new ArrayList<>();
            for ( String name : names )
            {
                for ( File file : eachFileConverter.apply( name ) )
                {
                    files.add( file );
                }
            }
            return files.toArray( new File[files.size()] );
        };
    }

    public static Function<String,File[]> toFiles( final String delimiter,
            final Function<String,File[]> eachFileConverter )
    {
        return new Function<String,File[]>()
        {
            @Override
            public File[] apply( String from )
            {
                if ( from == null )
                {
                    return new File[0];
                }

                String[] names = from.split( delimiter );
                List<File> files = new ArrayList<>();
                for ( String name : names )
                {
                    for ( File file : eachFileConverter.apply( name ) )
                    {
                        files.add( file );
                    }
                }
                return files.toArray( new File[files.size()] );
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.kernel.impl.util.Converters.toFiles.new Function<String,File[]> with from -> {if(from == null){return new File[0]; in method public toFiles(delimiter String, eachFileConverter Function<String,File[]>) : Function<String,File[]> from class org.neo4j.kernel.impl.util.Converters


    public static Function<String,Character> toCharacter()
    {
        return value -> {
            if ( value.length() > 1 )
            {
                throw new IllegalArgumentException( "Invalid delimiter '" +
                        value + "', expected one character" );
            }
            return value.charAt( 0 );
        };
    }

    public static Function<String,Character> toCharacter()
    {
        return new Function<String,Character>()
        {
            @Override
            public Character apply( String value )
            {
                if ( value.length() > 1 )
                {
                    throw new IllegalArgumentException( "Invalid delimiter '" +
                            value + "', expected one character" );
                }
                return value.charAt( 0 );
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.kernel.impl.util.Converters.toCharacter.new Function<String,Character> with value -> {if(value.length() > 1){throw new IllegalArgumentException("Invalid delimiter '" + value + "', expected one character"); in method public toCharacter() : Function<String,Character> from class org.neo4j.kernel.impl.util.Converters


            @Override
            public Iterator<Pair<String, String>> knownUniqueConstraints()
            {
                return Iterables.map( uniquenessConstraint -> {
                    String label = labels.byIdOrFail( uniquenessConstraint.label() );
                    String propertyKey = propertyKeys.byIdOrFail( uniquenessConstraint.propertyKey() );
                    return Pair.of( label, propertyKey );
                }, uniquenessConstraints.iterator() );
            }

            @Override
            public Iterator<Pair<String, String>> knownUniqueConstraints()
            {
                return Iterables.map( new Function<UniquenessConstraint,Pair<String,String>>()
                {
                    @Override
                    public Pair<String,String> apply( UniquenessConstraint uniquenessConstraint )
                            throws RuntimeException
                    {
                        String label = labels.byIdOrFail( uniquenessConstraint.label() );
                        String propertyKey = propertyKeys.byIdOrFail( uniquenessConstraint.propertyKey() );
                        return Pair.of( label, propertyKey );
                    }
                }, uniquenessConstraints.iterator() );
            }

Replace Anonymous With Lambda org.neo4j.kernel.impl.util.dbstructure.DbStructureCollector.lookup.new DbStructureLookup.knownUniqueConstraints.map.new Function<UniquenessConstraint,Pair<String,String>> with uniquenessConstraint -> {String label=labels.byIdOrFail(uniquenessConstraint.label()); in method public knownUniqueConstraints() : Iterator<Pair<String,String>> from class org.neo4j.kernel.impl.util.dbstructure.DbStructureCollector.lookup.new DbStructureLookup


            @Override
            public Iterator<Pair<String,String>> knownNodePropertyExistenceConstraints()
            {
                return Iterables.map( uniquenessConstraint -> {
                    String label = labels.byIdOrFail( uniquenessConstraint.label() );
                    String propertyKey = propertyKeys.byIdOrFail( uniquenessConstraint.propertyKey() );
                    return Pair.of( label, propertyKey );
                }, nodePropertyExistenceConstraints.iterator() );
            }

            @Override
            public Iterator<Pair<String,String>> knownNodePropertyExistenceConstraints()
            {
                return Iterables.map( new Function<NodePropertyExistenceConstraint,Pair<String,String>>()
                {
                    @Override
                    public Pair<String,String> apply( NodePropertyExistenceConstraint uniquenessConstraint )
                            throws RuntimeException
                    {
                        String label = labels.byIdOrFail( uniquenessConstraint.label() );
                        String propertyKey = propertyKeys.byIdOrFail( uniquenessConstraint.propertyKey() );
                        return Pair.of( label, propertyKey );
                    }
                }, nodePropertyExistenceConstraints.iterator() );
            }

Replace Anonymous With Lambda org.neo4j.kernel.impl.util.dbstructure.DbStructureCollector.lookup.new DbStructureLookup.knownNodePropertyExistenceConstraints.map.new Function<NodePropertyExistenceConstraint,Pair<String,String>> with uniquenessConstraint -> {String label=labels.byIdOrFail(uniquenessConstraint.label()); in method public knownNodePropertyExistenceConstraints() : Iterator<Pair<String,String>> from class org.neo4j.kernel.impl.util.dbstructure.DbStructureCollector.lookup.new DbStructureLookup


    /**
     * Ensures that all {@link InputNode input nodes} will at least have the given set of labels.
     */
    public static Function<InputNode,InputNode> additiveLabels( final String[] labelNamesToAdd )
    {
        if ( labelNamesToAdd == null || labelNamesToAdd.length == 0 )
        {
            return Functions.identity();
        }

        return node -> {
            if ( node.hasLabelField() )
            {
                return node;
            }

            String[] union = ArrayUtil.union( node.labels(), labelNamesToAdd );
            if ( union != node.labels() )
            {
                node.setLabels( union );
            }
            return node;
        };
    }

    /**
     * Ensures that all {@link InputNode input nodes} will at least have the given set of labels.
     */
    public static Function<InputNode,InputNode> additiveLabels( final String[] labelNamesToAdd )
    {
        if ( labelNamesToAdd == null || labelNamesToAdd.length == 0 )
        {
            return Functions.identity();
        }

        return new Function<InputNode,InputNode>()
        {
            @Override
            public InputNode apply( InputNode node )
            {
                if ( node.hasLabelField() )
                {
                    return node;
                }

                String[] union = ArrayUtil.union( node.labels(), labelNamesToAdd );
                if ( union != node.labels() )
                {
                    node.setLabels( union );
                }
                return node;
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.unsafe.impl.batchimport.input.InputEntityDecorators.additiveLabels.new Function<InputNode,InputNode> with node -> {if(node.hasLabelField()){return node; in method public additiveLabels(labelNamesToAdd String[]) : Function<InputNode,InputNode> from class org.neo4j.unsafe.impl.batchimport.input.InputEntityDecorators


    /**
     * Ensures that {@link InputRelationship input relationships} without a specified relationship type will get
     * the specified default relationship type.
     */
    public static Function<InputRelationship,InputRelationship> defaultRelationshipType( final String defaultType )
    {
        if ( defaultType == null )
        {
            return Functions.identity();
        }

        return relationship -> {
            if ( relationship.type() == null && !relationship.hasTypeId() )
            {
                relationship.setType( defaultType );
            }

            return relationship;
        };
    }

    /**
     * Ensures that {@link InputRelationship input relationships} without a specified relationship type will get
     * the specified default relationship type.
     */
    public static Function<InputRelationship,InputRelationship> defaultRelationshipType( final String defaultType )
    {
        if ( defaultType == null )
        {
            return Functions.identity();
        }

        return new Function<InputRelationship,InputRelationship>()
        {
            @Override
            public InputRelationship apply( InputRelationship relationship )
            {
                if ( relationship.type() == null && !relationship.hasTypeId() )
                {
                    relationship.setType( defaultType );
                }

                return relationship;
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.unsafe.impl.batchimport.input.InputEntityDecorators.defaultRelationshipType.new Function<InputRelationship,InputRelationship> with relationship -> {if(relationship.type() == null && !relationship.hasTypeId()){relationship.setType(defaultType); in method public defaultRelationshipType(defaultType String) : Function<InputRelationship,InputRelationship> from class org.neo4j.unsafe.impl.batchimport.input.InputEntityDecorators


    public static <ENTITY extends InputEntity> Function<ENTITY,ENTITY> decorators(
            final Function<ENTITY,ENTITY>... decorators )
    {
        return from -> {
            for ( Function<ENTITY,ENTITY> decorator : decorators )
            {
                from = decorator.apply( from );
            }
            return from;
        };
    }

    public static <ENTITY extends InputEntity> Function<ENTITY,ENTITY> decorators(
            final Function<ENTITY,ENTITY>... decorators )
    {
        return new Function<ENTITY,ENTITY>()
        {
            @Override
            public ENTITY apply( ENTITY from ) throws RuntimeException
            {
                for ( Function<ENTITY,ENTITY> decorator : decorators )
                {
                    from = decorator.apply( from );
                }
                return from;
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.unsafe.impl.batchimport.input.InputEntityDecorators.decorators.new Function<ENTITY,ENTITY> with from -> {for(Function<ENTITY,ENTITY> decorator: decorators){from=decorator.apply(from); in method public decorators(decorators Function<ENTITY,ENTITY>...) : Function<ENTITY,ENTITY> from class org.neo4j.unsafe.impl.batchimport.input.InputEntityDecorators


                    @Override
                    protected InputEntityDeserializer<InputRelationship> entityDeserializer( CharSeeker dataStream,
                              Header dataHeader, Function<InputRelationship,InputRelationship> decorator )
                    {
                        return new InputEntityDeserializer<>( dataHeader, dataStream, config.delimiter(),
                                new InputRelationshipDeserialization( dataStream, dataHeader, groups ),
                                decorator, entity -> {
                                    if ( entity.startNode() == null )
                                    {
                                        throw new MissingRelationshipDataException(Type.START_ID,
                                                            entity + " is missing " + Type.START_ID + " field" );
                                    }
                                    if ( entity.endNode() == null )
                                    {
                                        throw new MissingRelationshipDataException(Type.END_ID,
                                                            entity + " is missing " + Type.END_ID + " field" );
                                    }
                                    if ( !entity.hasTypeId() && entity.type() == null )
                                    {
                                        throw new MissingRelationshipDataException(Type.TYPE,
                                                            entity + " is missing " + Type.TYPE + " field" );
                                    }
                                }, badCollector );
                    }

                    @Override
                    protected InputEntityDeserializer<InputRelationship> entityDeserializer( CharSeeker dataStream,
                              Header dataHeader, Function<InputRelationship,InputRelationship> decorator )
                    {
                        return new InputEntityDeserializer<>( dataHeader, dataStream, config.delimiter(),
                                new InputRelationshipDeserialization( dataStream, dataHeader, groups ),
                                decorator, new Validator<InputRelationship>()
                                {
                                    @Override
                                    public void validate( InputRelationship entity )
                                    {
                                        if ( entity.startNode() == null )
                                        {
                                            throw new MissingRelationshipDataException(Type.START_ID,
                                                                entity + " is missing " + Type.START_ID + " field" );
                                        }
                                        if ( entity.endNode() == null )
                                        {
                                            throw new MissingRelationshipDataException(Type.END_ID,
                                                                entity + " is missing " + Type.END_ID + " field" );
                                        }
                                        if ( !entity.hasTypeId() && entity.type() == null )
                                        {
                                            throw new MissingRelationshipDataException(Type.TYPE,
                                                                entity + " is missing " + Type.TYPE + " field" );
                                        }
                                    }
                                }, badCollector );
                    }

Replace Anonymous With Lambda org.neo4j.unsafe.impl.batchimport.input.csv.CsvInput.relationships.new InputIterable<InputRelationship>.iterator.new InputGroupsDeserializer<InputRelationship>.entityDeserializer.new InputEntityDeserializer<>.new Validator<InputRelationship> with entity -> {if(entity.startNode() == null){throw new MissingRelationshipDataException(Type.START_ID,entity + " is missing " + Type.START_ID + " field"); in method protected entityDeserializer(dataStream CharSeeker, dataHeader Header, decorator Function<InputRelationship,InputRelationship>) : InputEntityDeserializer<InputRelationship> from class org.neo4j.unsafe.impl.batchimport.input.csv.CsvInput.relationships.new InputIterable<InputRelationship>.iterator.new InputGroupsDeserializer<InputRelationship>


    @Test
    public void shouldEncodeProperlyWithMultipleThreadsRacing() throws Exception
    {
        // given
        String[] INPUT = {
                "These strings need to be longer than 57 bytes, because that is the line wrapping length of BASE64.",
                "This next line is also long. The number of strings in this array is the number of threads to use.",
                "Each thread will get a different string as input to encode, and ensure the result is always the same.",
                "Should the result of an encoding differ even once, the thread will yield a negative overall result.",
                "If any of the threads yields a negative result, the test will fail, since that should not happen.",
                "All threads are allowed to run together for a predetermined amount of time, to try to get contention.",
                "This predetermined time is the minimum runtime of the test, since the timer starts after all threads.",
                "The idea to use the input data as documentation for the test was just a cute thing I came up with.",
                "Since my imagination for coming up with test data is usually poor, I figured I'd do something useful.",
                "Hopefully this isn't just nonsensical drivel, and maybe, just maybe someone might actually read it."};
        long executionTime = SECONDS.toMillis( 5 );
        final AtomicBoolean running = new AtomicBoolean( true );
        ThrowingFunction<String, Boolean, RuntimeException> function = input -> {
            String first = ArrayEncoder.encode( new String[]{input} );
            do
            {
                if ( !first.equals( ArrayEncoder.encode( new String[]{input} ) ) )
                {
                    return false;
                }
            } while ( running.get() );
            return true;
        };
        List<Future<Boolean>> futures = new ArrayList<>();

        // when
        for ( String input : INPUT )
        {
            futures.add( threads.execute( function, input ) );
        }

        Thread.sleep( executionTime );
        running.set( false );

        // then
        for ( Future<Boolean> future : futures )
        {
            assertTrue( "Each attempt at encoding should yield the same result.", future.get() );
        }
    }

    @Test
    public void shouldEncodeProperlyWithMultipleThreadsRacing() throws Exception
    {
        // given
        String[] INPUT = {
                "These strings need to be longer than 57 bytes, because that is the line wrapping length of BASE64.",
                "This next line is also long. The number of strings in this array is the number of threads to use.",
                "Each thread will get a different string as input to encode, and ensure the result is always the same.",
                "Should the result of an encoding differ even once, the thread will yield a negative overall result.",
                "If any of the threads yields a negative result, the test will fail, since that should not happen.",
                "All threads are allowed to run together for a predetermined amount of time, to try to get contention.",
                "This predetermined time is the minimum runtime of the test, since the timer starts after all threads.",
                "The idea to use the input data as documentation for the test was just a cute thing I came up with.",
                "Since my imagination for coming up with test data is usually poor, I figured I'd do something useful.",
                "Hopefully this isn't just nonsensical drivel, and maybe, just maybe someone might actually read it."};
        long executionTime = SECONDS.toMillis( 5 );
        final AtomicBoolean running = new AtomicBoolean( true );
        Function<String, Boolean> function = new Function<String, Boolean>()
        {
            @Override
            public Boolean apply( String input )
            {
                String first = ArrayEncoder.encode( new String[]{input} );
                do
                {
                    if ( !first.equals( ArrayEncoder.encode( new String[]{input} ) ) )
                    {
                        return false;
                    }
                } while ( running.get() );
                return true;
            }
        };
        List<Future<Boolean>> futures = new ArrayList<>();

        // when
        for ( String input : INPUT )
        {
            futures.add( threads.execute( function, input ) );
        }

        Thread.sleep( executionTime );
        running.set( false );

        // then
        for ( Future<Boolean> future : futures )
        {
            assertTrue( "Each attempt at encoding should yield the same result.", future.get() );
        }
    }

Replace Anonymous With Lambda org.neo4j.kernel.api.index.ArrayEncoderTest.shouldEncodeProperlyWithMultipleThreadsRacing.function.new Function<String,Boolean> with input -> {String first=ArrayEncoder.encode(new String[]{input}); in method public shouldEncodeProperlyWithMultipleThreadsRacing() : void from class org.neo4j.kernel.api.index.ArrayEncoderTest


    @Parameterized.Parameters(name = "{0}")
    public static Collection<Object[]> data()
    {
        Iterable<Test> testValues = asIterable(
                // boolean properties
                shouldMatch( true, true ),
                shouldMatch( false, false ),
                shouldNotMatch( true, false ),
                shouldNotMatch( false, true ),
                shouldNotMatch( true, 0 ),
                shouldNotMatch( false, 0 ),
                shouldNotMatch( true, 1 ),
                shouldNotMatch( false, 1 ),
                shouldNotMatch( false, "false" ),
                shouldNotMatch( true, "true" ),

                //byte properties
                shouldMatch( (byte) 42, (byte) 42 ),
                shouldMatch( (byte) 42, (short) 42 ),
                shouldNotMatch( (byte) 42, 42 + 256 ),
                shouldMatch( (byte) 43, (int) 43 ),
                shouldMatch( (byte) 43, (long) 43 ),
                shouldMatch( (byte) 23, 23.0d ),
                shouldMatch( (byte) 23, 23.0f ),
                shouldNotMatch( (byte) 23, 23.5 ),
                shouldNotMatch( (byte) 23, 23.5f ),

                //short properties
                shouldMatch( (short) 11, (byte) 11 ),
                shouldMatch( (short) 42, (short) 42 ),
                shouldNotMatch( (short) 42, 42 + 65536 ),
                shouldMatch( (short) 43, (int) 43 ),
                shouldMatch( (short) 43, (long) 43 ),
                shouldMatch( (short) 23, 23.0f ),
                shouldMatch( (short) 23, 23.0d ),
                shouldNotMatch( (short) 23, 23.5 ),
                shouldNotMatch( (short) 23, 23.5f ),

                //int properties
                shouldMatch( 11, (byte) 11 ),
                shouldMatch( 42, (short) 42 ),
                shouldNotMatch( 42, 42 + 4294967296L ),
                shouldMatch( 43, 43 ),
                shouldMatch( Integer.MAX_VALUE, Integer.MAX_VALUE ),
                shouldMatch( 43, (long) 43 ),
                shouldMatch( 23, 23.0 ),
                shouldNotMatch( 23, 23.5 ),
                shouldNotMatch( 23, 23.5f ),

                //long properties
                shouldMatch( 11L, (byte) 11 ),
                shouldMatch( 42L, (short) 42 ),
                shouldMatch( 43L, (int) 43 ),
                shouldMatch( 43L, (long) 43 ),
                shouldMatch( 87L, (long) 87 ),
                shouldMatch( Long.MAX_VALUE, Long.MAX_VALUE ),
                shouldMatch( 23L, 23.0 ),
                shouldNotMatch( 23L, 23.5 ),
                shouldNotMatch( 23L, 23.5f ),
                shouldMatch(9007199254740992L, 9007199254740992D),
                // shouldMatch(9007199254740993L, 9007199254740992D), // is stupid, m'kay?!

                // floats goddamnit
                shouldMatch( 11f, (byte) 11 ),
                shouldMatch( 42f, (short) 42 ),
                shouldMatch( 43f, (int) 43 ),
                shouldMatch( 43f, (long) 43 ),
                shouldMatch( 23f, 23.0 ),
                shouldNotMatch( 23f, 23.5 ),
                shouldNotMatch( 23f, 23.5f ),
                shouldMatch( 3.14f, 3.14f ),
                shouldNotMatch( 3.14f, 3.14d ),   // Would be nice if they matched, but they don't

                // doubles
                shouldMatch( 11d, (byte) 11 ),
                shouldMatch( 42d, (short) 42 ),
                shouldMatch( 43d, (int) 43 ),
                shouldMatch( 43d, (long) 43 ),
                shouldMatch( 23d, 23.0 ),
                shouldNotMatch( 23d, 23.5 ),
                shouldNotMatch( 23d, 23.5f ),
                shouldNotMatch( 3.14d, 3.14f ),   // this really is sheeeet
                shouldMatch( 3.14d, 3.14d ),

                // strings
                shouldMatch( "A", "A" ),
                shouldMatch( 'A', 'A' ),
                shouldMatch( 'A', "A" ),
                shouldMatch( "A", 'A' ),
                shouldNotMatch( "AA", 'A' ),
                shouldNotMatch( "a", "A" ),
                shouldNotMatch( "A", "a" ),
                shouldNotMatch( "0", 0 ),
                shouldNotMatch( '0', 0 ),

                // arrays
                shouldMatch( new int[]{1, 2, 3}, new int[]{1, 2, 3} ),
                shouldMatch( new int[]{1, 2, 3}, new long[]{1, 2, 3} ),
                shouldMatch( new int[]{1, 2, 3}, new double[]{1.0, 2.0, 3.0} ),
                shouldMatch( new String[]{"A", "B", "C"}, new String[]{"A", "B", "C"} ),
                shouldMatch( new String[]{"A", "B", "C"}, new char[]{'A', 'B', 'C'} ),
                shouldMatch( new char[]{'A', 'B', 'C'},  new String[]{"A", "B", "C"} )
        );
        return asCollection( map( testValue -> {
            return new Object[]{testValue};
        }, testValues ) );
    }

    @Parameterized.Parameters(name = "{0}")
    public static Collection<Object[]> data()
    {
        Iterable<Test> testValues = asIterable(
                // boolean properties
                shouldMatch( true, true ),
                shouldMatch( false, false ),
                shouldNotMatch( true, false ),
                shouldNotMatch( false, true ),
                shouldNotMatch( true, 0 ),
                shouldNotMatch( false, 0 ),
                shouldNotMatch( true, 1 ),
                shouldNotMatch( false, 1 ),
                shouldNotMatch( false, "false" ),
                shouldNotMatch( true, "true" ),

                //byte properties
                shouldMatch( (byte) 42, (byte) 42 ),
                shouldMatch( (byte) 42, (short) 42 ),
                shouldNotMatch( (byte) 42, 42 + 256 ),
                shouldMatch( (byte) 43, (int) 43 ),
                shouldMatch( (byte) 43, (long) 43 ),
                shouldMatch( (byte) 23, 23.0d ),
                shouldMatch( (byte) 23, 23.0f ),
                shouldNotMatch( (byte) 23, 23.5 ),
                shouldNotMatch( (byte) 23, 23.5f ),

                //short properties
                shouldMatch( (short) 11, (byte) 11 ),
                shouldMatch( (short) 42, (short) 42 ),
                shouldNotMatch( (short) 42, 42 + 65536 ),
                shouldMatch( (short) 43, (int) 43 ),
                shouldMatch( (short) 43, (long) 43 ),
                shouldMatch( (short) 23, 23.0f ),
                shouldMatch( (short) 23, 23.0d ),
                shouldNotMatch( (short) 23, 23.5 ),
                shouldNotMatch( (short) 23, 23.5f ),

                //int properties
                shouldMatch( 11, (byte) 11 ),
                shouldMatch( 42, (short) 42 ),
                shouldNotMatch( 42, 42 + 4294967296L ),
                shouldMatch( 43, 43 ),
                shouldMatch( Integer.MAX_VALUE, Integer.MAX_VALUE ),
                shouldMatch( 43, (long) 43 ),
                shouldMatch( 23, 23.0 ),
                shouldNotMatch( 23, 23.5 ),
                shouldNotMatch( 23, 23.5f ),

                //long properties
                shouldMatch( 11L, (byte) 11 ),
                shouldMatch( 42L, (short) 42 ),
                shouldMatch( 43L, (int) 43 ),
                shouldMatch( 43L, (long) 43 ),
                shouldMatch( 87L, (long) 87 ),
                shouldMatch( Long.MAX_VALUE, Long.MAX_VALUE ),
                shouldMatch( 23L, 23.0 ),
                shouldNotMatch( 23L, 23.5 ),
                shouldNotMatch( 23L, 23.5f ),
                shouldMatch(9007199254740992L, 9007199254740992D),
                // shouldMatch(9007199254740993L, 9007199254740992D), // is stupid, m'kay?!

                // floats goddamnit
                shouldMatch( 11f, (byte) 11 ),
                shouldMatch( 42f, (short) 42 ),
                shouldMatch( 43f, (int) 43 ),
                shouldMatch( 43f, (long) 43 ),
                shouldMatch( 23f, 23.0 ),
                shouldNotMatch( 23f, 23.5 ),
                shouldNotMatch( 23f, 23.5f ),
                shouldMatch( 3.14f, 3.14f ),
                shouldNotMatch( 3.14f, 3.14d ),   // Would be nice if they matched, but they don't

                // doubles
                shouldMatch( 11d, (byte) 11 ),
                shouldMatch( 42d, (short) 42 ),
                shouldMatch( 43d, (int) 43 ),
                shouldMatch( 43d, (long) 43 ),
                shouldMatch( 23d, 23.0 ),
                shouldNotMatch( 23d, 23.5 ),
                shouldNotMatch( 23d, 23.5f ),
                shouldNotMatch( 3.14d, 3.14f ),   // this really is sheeeet
                shouldMatch( 3.14d, 3.14d ),

                // strings
                shouldMatch( "A", "A" ),
                shouldMatch( 'A', 'A' ),
                shouldMatch( 'A', "A" ),
                shouldMatch( "A", 'A' ),
                shouldNotMatch( "AA", 'A' ),
                shouldNotMatch( "a", "A" ),
                shouldNotMatch( "A", "a" ),
                shouldNotMatch( "0", 0 ),
                shouldNotMatch( '0', 0 ),

                // arrays
                shouldMatch( new int[]{1, 2, 3}, new int[]{1, 2, 3} ),
                shouldMatch( new int[]{1, 2, 3}, new long[]{1, 2, 3} ),
                shouldMatch( new int[]{1, 2, 3}, new double[]{1.0, 2.0, 3.0} ),
                shouldMatch( new String[]{"A", "B", "C"}, new String[]{"A", "B", "C"} ),
                shouldMatch( new String[]{"A", "B", "C"}, new char[]{'A', 'B', 'C'} ),
                shouldMatch( new char[]{'A', 'B', 'C'},  new String[]{"A", "B", "C"} )
        );
        return asCollection( map( new Function<Test, Object[]>()
        {
            @Override
            public Object[] apply( Test testValue )
            {
                return new Object[]{testValue};
            }
        }, testValues ) );
    }

Replace Anonymous With Lambda org.neo4j.kernel.api.properties.PropertyEqualityTest.data.asCollection.map.new Function<Test,Object[]> with testValue -> {return new Object[]{testValue}; in method public data() : Collection<Object[]> from class org.neo4j.kernel.api.properties.PropertyEqualityTest


    private static Function<GraphDatabaseService, Void> expectFailureAfterSchemaOperation(
            final Function<GraphDatabaseService, ?> function )
    {
        return graphDb -> {
            // given
            graphDb.schema().indexFor( label( "Label1" ) ).on( "key1" ).create();

            // when
            try
            {
                function.apply( graphDb );

                fail( "expected exception" );
            }
            // then
            catch ( Exception e )
            {
                assertEquals( "Cannot perform data updates in a transaction that has performed schema updates.",
                        e.getMessage() );
            }
            return null;
        };
    }

    private static Function<GraphDatabaseService, Void> expectFailureAfterSchemaOperation(
            final Function<GraphDatabaseService, ?> function )
    {
        return new Function<GraphDatabaseService, Void>()
        {
            @Override
            public Void apply( GraphDatabaseService graphDb )
            {
                // given
                graphDb.schema().indexFor( label( "Label1" ) ).on( "key1" ).create();

                // when
                try
                {
                    function.apply( graphDb );

                    fail( "expected exception" );
                }
                // then
                catch ( Exception e )
                {
                    assertEquals( "Cannot perform data updates in a transaction that has performed schema updates.",
                            e.getMessage() );
                }
                return null;
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.kernel.impl.api.DataAndSchemaTransactionSeparationIT.expectFailureAfterSchemaOperation.new Function<GraphDatabaseService,Void> with graphDb -> {graphDb.schema().indexFor(label("Label1")).on("key1").create(); in method private expectFailureAfterSchemaOperation(function Function<GraphDatabaseService,?>) : Function<GraphDatabaseService,Void> from class org.neo4j.kernel.impl.api.DataAndSchemaTransactionSeparationIT


    private static Function<GraphDatabaseService, Void> succeedAfterSchemaOperation(
            final Function<GraphDatabaseService, ?> function )
    {
        return graphDb -> {
            // given
            graphDb.schema().indexFor( label( "Label1" ) ).on( "key1" ).create();

            // when/then
            function.apply( graphDb );
            return null;
        };
    }

    private static Function<GraphDatabaseService, Void> succeedAfterSchemaOperation(
            final Function<GraphDatabaseService, ?> function )
    {
        return new Function<GraphDatabaseService, Void>()
        {
            @Override
            public Void apply( GraphDatabaseService graphDb )
            {
                // given
                graphDb.schema().indexFor( label( "Label1" ) ).on( "key1" ).create();

                // when/then
                function.apply( graphDb );
                return null;
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.kernel.impl.api.DataAndSchemaTransactionSeparationIT.succeedAfterSchemaOperation.new Function<GraphDatabaseService,Void> with graphDb -> {graphDb.schema().indexFor(label("Label1")).on("key1").create(); in method private succeedAfterSchemaOperation(function Function<GraphDatabaseService,?>) : Function<GraphDatabaseService,Void> from class org.neo4j.kernel.impl.api.DataAndSchemaTransactionSeparationIT