    @Deprecated
    public static Predicate<StackTraceElement> classImplementingInterface( final Class<Client> cls )
    {
        return item -> {
            try
            {
                for ( Class<?> interfaceClass : Class.forName( item.getClassName() ).getInterfaces() )
                {
                    if ( interfaceClass.equals( cls ) )
                    {
                        return true;
                    }
                }
                return false;
            }
            catch ( ClassNotFoundException e )
            {
                return false;
            }
        };
    }

    @Deprecated
    public static Predicate<StackTraceElement> classImplementingInterface( final Class<Client> cls )
    {
        return new Predicate<StackTraceElement>()
        {
            @Override
            public boolean accept( StackTraceElement item )
            {
                try
                {
                    for ( Class<?> interfaceClass : Class.forName( item.getClassName() ).getInterfaces() )
                    {
                        if ( interfaceClass.equals( cls ) )
                        {
                            return true;
                        }
                    }
                    return false;
                }
                catch ( ClassNotFoundException e )
                {
                    return false;
                }
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.helpers.Exceptions.classImplementingInterface.new Predicate<StackTraceElement> with item -> {tryfor(Class<?> interfaceClass: Class.forName(item.getClassName()).getInterfaces()){if(interfaceClass.equals(cls)){return true; in method public classImplementingInterface(cls Class<Client>) : Predicate<StackTraceElement> from class org.neo4j.helpers.Exceptions


    @Deprecated
    public static boolean containsStackTraceElement( Throwable cause,
            final Predicate<StackTraceElement> predicate )
    {
        return contains( cause, item -> {
            for ( StackTraceElement element : item.getStackTrace() )
            {
                if ( predicate.test( element ) )
                {
                    return true;
                }
            }
            return false;
        } );
    }

    @Deprecated
    public static boolean containsStackTraceElement( Throwable cause,
            final Predicate<StackTraceElement> predicate )
    {
        return contains( cause, new org.neo4j.function.Predicate<Throwable>()
        {
            @Override
            public boolean test( Throwable item )
            {
                for ( StackTraceElement element : item.getStackTrace() )
                {
                    if ( predicate.accept( element ) )
                    {
                        return true;
                    }
                }
                return false;
            }
        } );
    }

Replace Anonymous With Lambda org.neo4j.helpers.Exceptions.containsStackTraceElement.contains.new org.neo4j.function.Predicate<Throwable> with item -> {for(StackTraceElement element: item.getStackTrace()){if(predicate.test(element)){return true; in method public containsStackTraceElement(cause Throwable, predicate Predicate<StackTraceElement>) : boolean from class org.neo4j.helpers.Exceptions


    public static <T> Iterable<T> limit( final int limitItems, final Iterable<T> iterable )
    {
        return () -> {
            final Iterator<T> iterator = iterable.iterator();

            return new Iterator<T>()
            {
                int count;

                @Override
                public boolean hasNext()
                {
                    return count < limitItems && iterator.hasNext();
                }

                @Override
                public T next()
                {
                    count++;
                    return iterator.next();
                }

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

    public static <T> Iterable<T> limit( final int limitItems, final Iterable<T> iterable )
    {
        return new Iterable<T>()
        {
            @Override
            public Iterator<T> iterator()
            {
                final Iterator<T> iterator = iterable.iterator();

                return new Iterator<T>()
                {
                    int count;

                    @Override
                    public boolean hasNext()
                    {
                        return count < limitItems && iterator.hasNext();
                    }

                    @Override
                    public T next()
                    {
                        count++;
                        return iterator.next();
                    }

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

Replace Anonymous With Lambda org.neo4j.helpers.collection.Iterables.limit.new Iterable<T> with () -> {final Iterator<T> iterator=iterable.iterator(); in method public limit(limitItems int, iterable Iterable<T>) : Iterable<T> from class org.neo4j.helpers.collection.Iterables


    public static <T> Iterable<T> unique( final Iterable<T> iterable )
    {
        return () -> {
            final Iterator<T> iterator = iterable.iterator();

            return new Iterator<T>()
            {
                Set<T> items = new HashSet<>();
                T nextItem;

                @Override
                public boolean hasNext()
                {
                    while ( iterator.hasNext() )
                    {
                        nextItem = iterator.next();
                        if ( items.add( nextItem ) )
                        {
                            return true;
                        }
                    }

                    return false;
                }

                @Override
                public T next()
                {
                    if ( nextItem == null && !hasNext() )
                    {
                        throw new NoSuchElementException();
                    }

                    return nextItem;
                }

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

    public static <T> Iterable<T> unique( final Iterable<T> iterable )
    {
        return new Iterable<T>()
        {
            @Override
            public Iterator<T> iterator()
            {
                final Iterator<T> iterator = iterable.iterator();

                return new Iterator<T>()
                {
                    Set<T> items = new HashSet<>();
                    T nextItem;

                    @Override
                    public boolean hasNext()
                    {
                        while ( iterator.hasNext() )
                        {
                            nextItem = iterator.next();
                            if ( items.add( nextItem ) )
                            {
                                return true;
                            }
                        }

                        return false;
                    }

                    @Override
                    public T next()
                    {
                        if ( nextItem == null && !hasNext() )
                        {
                            throw new NoSuchElementException();
                        }

                        return nextItem;
                    }

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

Replace Anonymous With Lambda org.neo4j.helpers.collection.Iterables.unique.new Iterable<T> with () -> {final Iterator<T> iterator=iterable.iterator(); in method public unique(iterable Iterable<T>) : Iterable<T> from class org.neo4j.helpers.collection.Iterables


    public static <X> Iterable<X> skip( final int skip, final Iterable<X> iterable )
    {
        return () -> {
            Iterator<X> iterator = iterable.iterator();

            for ( int i = 0; i < skip; i++ )
            {
                if ( iterator.hasNext() )
                {
                    iterator.next();
                }
                else
                {
                    return Iterables.<X>empty().iterator();
                }
            }

            return iterator;
        };
    }

    public static <X> Iterable<X> skip( final int skip, final Iterable<X> iterable )
    {
        return new Iterable<X>()
        {
            @Override
            public Iterator<X> iterator()
            {
                Iterator<X> iterator = iterable.iterator();

                for ( int i = 0; i < skip; i++ )
                {
                    if ( iterator.hasNext() )
                    {
                        iterator.next();
                    }
                    else
                    {
                        return Iterables.<X>empty().iterator();
                    }
                }

                return iterator;
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.helpers.collection.Iterables.skip.new Iterable<X> with () -> {Iterator<X> iterator=iterable.iterator(); in method public skip(skip int, iterable Iterable<X>) : Iterable<X> from class org.neo4j.helpers.collection.Iterables


    @SafeVarargs
    public static <T> Iterable<T> mix( final Iterable<T>... iterables )
    {
        return () -> {
            final Iterable<Iterator<T>> iterators = toList( map( new Function<Iterable<T>, Iterator<T>>()
            {
                @Override
                public Iterator<T> apply( Iterable<T> iterable )
                {
                    return iterable.iterator();
                }
            }, asList(iterables) ) );

            return new Iterator<T>()
            {
                Iterator<Iterator<T>> iterator;

                Iterator<T> iter;

                @Override
                public boolean hasNext()
                {
                    for ( Iterator<T> iterator : iterators )
                    {
                        if ( iterator.hasNext() )
                        {
                            return true;
                        }
                    }

                    return false;
                }

                @Override
                public T next()
                {
                    if ( iterator == null )
                    {
                        iterator = iterators.iterator();
                    }

                    while ( iterator.hasNext() )
                    {
                        iter = iterator.next();

                        if ( iter.hasNext() )
                        {
                            return iter.next();
                        }
                    }

                    iterator = null;

                    return next();
                }

                @Override
                public void remove()
                {
                    if ( iter != null )
                    {
                        iter.remove();
                    }
                }
            };
        };
    }

    @SafeVarargs
    public static <T> Iterable<T> mix( final Iterable<T>... iterables )
    {
        return new Iterable<T>()
        {
            @Override
            public Iterator<T> iterator()
            {
                final Iterable<Iterator<T>> iterators = toList( map( new Function<Iterable<T>, Iterator<T>>()
                {
                    @Override
                    public Iterator<T> apply( Iterable<T> iterable )
                    {
                        return iterable.iterator();
                    }
                }, asList(iterables) ) );

                return new Iterator<T>()
                {
                    Iterator<Iterator<T>> iterator;

                    Iterator<T> iter;

                    @Override
                    public boolean hasNext()
                    {
                        for ( Iterator<T> iterator : iterators )
                        {
                            if ( iterator.hasNext() )
                            {
                                return true;
                            }
                        }

                        return false;
                    }

                    @Override
                    public T next()
                    {
                        if ( iterator == null )
                        {
                            iterator = iterators.iterator();
                        }

                        while ( iterator.hasNext() )
                        {
                            iter = iterator.next();

                            if ( iter.hasNext() )
                            {
                                return iter.next();
                            }
                        }

                        iterator = null;

                        return next();
                    }

                    @Override
                    public void remove()
                    {
                        if ( iter != null )
                        {
                            iter.remove();
                        }
                    }
                };
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.helpers.collection.Iterables.mix.new Iterable<T> with () -> {final Iterable<Iterator<T>> iterators=toList(map(new Function<Iterable<T>,Iterator<T>>(){ in method public mix(iterables Iterable<T>...) : Iterable<T> from class org.neo4j.helpers.collection.Iterables


    public static <T, C extends T> Iterable<T> prepend( final C item, final Iterable<T> iterable )
    {
        return () -> new Iterator<T>()
        {
            T first = item;
            Iterator<T> iterator;

            @Override
            public boolean hasNext()
            {
                if ( first != null )
                {
                    return true;
                }
                else
                {
                    if ( iterator == null )
                    {
                        iterator = iterable.iterator();
                    }
                }

                return iterator.hasNext();
            }

            @Override
            public T next()
            {
                if ( first != null )
                {
                    try
                    {
                        return first;
                    }
                    finally
                    {
                        first = null;
                    }
                }
                else
                {
                    return iterator.next();
                }
            }

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

    public static <T, C extends T> Iterable<T> prepend( final C item, final Iterable<T> iterable )
    {
        return new Iterable<T>()
        {
            @Override
            public Iterator<T> iterator()
            {
                return new Iterator<T>()
                {
                    T first = item;
                    Iterator<T> iterator;

                    @Override
                    public boolean hasNext()
                    {
                        if ( first != null )
                        {
                            return true;
                        }
                        else
                        {
                            if ( iterator == null )
                            {
                                iterator = iterable.iterator();
                            }
                        }

                        return iterator.hasNext();
                    }

                    @Override
                    public T next()
                    {
                        if ( first != null )
                        {
                            try
                            {
                                return first;
                            }
                            finally
                            {
                                first = null;
                            }
                        }
                        else
                        {
                            return iterator.next();
                        }
                    }

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

Replace Anonymous With Lambda org.neo4j.helpers.collection.Iterables.prepend.new Iterable<T> with () -> new Iterator<T>(){ in method public prepend(item C, iterable Iterable<T>) : Iterable<T> from class org.neo4j.helpers.collection.Iterables


    public static <T, C extends T> Iterable<T> append( final C item, final Iterable<T> iterable )
    {
        return () -> {
            final Iterator<T> iterator = iterable.iterator();

            return new Iterator<T>()
            {
                T last = item;

                @Override
                public boolean hasNext()
                {
                    return iterator.hasNext() || last != null;
                }

                @Override
                public T next()
                {
                    if ( iterator.hasNext() )
                    {
                        return iterator.next();
                    }
                    else
                    {
                        try
                        {
                            return last;
                        }
                        finally
                        {
                            last = null;
                        }
                    }
                }

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

    public static <T, C extends T> Iterable<T> append( final C item, final Iterable<T> iterable )
    {
        return new Iterable<T>()
        {
            @Override
            public Iterator<T> iterator()
            {
                final Iterator<T> iterator = iterable.iterator();

                return new Iterator<T>()
                {
                    T last = item;

                    @Override
                    public boolean hasNext()
                    {
                        return iterator.hasNext() || last != null;
                    }

                    @Override
                    public T next()
                    {
                        if ( iterator.hasNext() )
                        {
                            return iterator.next();
                        }
                        else
                        {
                            try
                            {
                                return last;
                            }
                            finally
                            {
                                last = null;
                            }
                        }
                    }

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

Replace Anonymous With Lambda org.neo4j.helpers.collection.Iterables.append.new Iterable<T> with () -> {final Iterator<T> iterator=iterable.iterator(); in method public append(item C, iterable Iterable<T>) : Iterable<T> from class org.neo4j.helpers.collection.Iterables


    public static <T> ResourceIterable<T> iterable( final IOCursor<T> cursor )
    {
        return () -> {
            try
            {
                if ( cursor.next() )
                {
                    final T first = cursor.get();

                    return new ResourceIterator<T>()
                    {
                        T instance = first;

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

                        @Override
                        public T next()
                        {
                            try
                            {
                                return instance;
                            }
                            finally
                            {
                                try
                                {
                                    if ( cursor.next() )
                                    {
                                        instance = cursor.get();
                                    }
                                    else
                                    {
                                        cursor.close();
                                        instance = null;
                                    }
                                }
                                catch ( IOException e )
                                {
                                    instance = null;
                                }
                            }
                        }

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

                        @Override
                        public void close()
                        {
                            try
                            {
                                cursor.close();
                            }
                            catch ( IOException e )
                            {
                                // Ignore
                            }
                        }
                    };
                }
                else
                {
                    cursor.close();
                    return IteratorUtil.<T>asResourceIterator( Collections.<T>emptyIterator() );
                }
            }
            catch ( IOException e )
            {
                return IteratorUtil.<T>asResourceIterator( Collections.<T>emptyIterator() );
            }
        };
    }

    public static <T> ResourceIterable<T> iterable( final IOCursor<T> cursor )
    {
        return new ResourceIterable<T>()
        {
            @Override
            public ResourceIterator<T> iterator()
            {
                try
                {
                    if ( cursor.next() )
                    {
                        final T first = cursor.get();

                        return new ResourceIterator<T>()
                        {
                            T instance = first;

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

                            @Override
                            public T next()
                            {
                                try
                                {
                                    return instance;
                                }
                                finally
                                {
                                    try
                                    {
                                        if ( cursor.next() )
                                        {
                                            instance = cursor.get();
                                        }
                                        else
                                        {
                                            cursor.close();
                                            instance = null;
                                        }
                                    }
                                    catch ( IOException e )
                                    {
                                        instance = null;
                                    }
                                }
                            }

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

                            @Override
                            public void close()
                            {
                                try
                                {
                                    cursor.close();
                                }
                                catch ( IOException e )
                                {
                                    // Ignore
                                }
                            }
                        };
                    }
                    else
                    {
                        cursor.close();
                        return IteratorUtil.<T>asResourceIterator( Collections.<T>emptyIterator() );
                    }
                }
                catch ( IOException e )
                {
                    return IteratorUtil.<T>asResourceIterator( Collections.<T>emptyIterator() );
                }
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.helpers.collection.Iterables.iterable.new ResourceIterable<T> with () -> {tryif(cursor.next()){final T first=cursor.get(); in method public iterable(cursor IOCursor<T>) : ResourceIterable<T> from class org.neo4j.helpers.collection.Iterables


        @Override
        Iterator<Relationship> doExpand( Path path, BranchState state )
        {
            final Node node = path.endNode();
            return new FilteringIterator<>(
                    node.getRelationships().iterator(),
                    rel -> {
                        Exclusion exclude = exclusion.get( rel.getType().name() );
                        exclude = (exclude == null) ? defaultExclusion
                                : exclude;
                        return exclude.accept( node, rel );
                    } );
        }

        @Override
        Iterator<Relationship> doExpand( Path path, BranchState state )
        {
            final Node node = path.endNode();
            return new FilteringIterator<Relationship>(
                    node.getRelationships().iterator(),
                    new Predicate<Relationship>()
                    {
                        public boolean test( Relationship rel )
                        {
                            Exclusion exclude = exclusion.get( rel.getType().name() );
                            exclude = (exclude == null) ? defaultExclusion
                                    : exclude;
                            return exclude.accept( node, rel );
                        }
                    } );
        }

Replace Anonymous With Lambda org.neo4j.kernel.StandardExpander.ExcludingExpander.doExpand.new FilteringIterator<Relationship>.new Predicate<Relationship> with rel -> {Exclusion exclude=exclusion.get(rel.getType().name()); in method package doExpand(path Path, state BranchState) : Iterator<Relationship> from class org.neo4j.kernel.StandardExpander.ExcludingExpander


        @Override
        Iterator<Relationship> doExpand( final Path path, BranchState state )
        {
            return new FilteringIterator<>( expander.doExpand( path, state ), item -> {
                Path extendedPath = extend( path, item );
                for ( Filter filter : filters )
                {
                    if ( filter.exclude( extendedPath ) )
                    {
                        return false;
                    }
                }
                return true;
            } );
        }

        @Override
        Iterator<Relationship> doExpand( final Path path, BranchState state )
        {
            return new FilteringIterator<Relationship>(
                    expander.doExpand( path, state ), new Predicate<Relationship>()
            {
                public boolean test( Relationship item )
                {
                    Path extendedPath = extend( path, item );
                    for ( Filter filter : filters )
                    {
                        if ( filter.exclude( extendedPath ) )
                        {
                            return false;
                        }
                    }
                    return true;
                }
            } );
        }

Replace Anonymous With Lambda org.neo4j.kernel.StandardExpander.FilteringExpander.doExpand.new FilteringIterator<Relationship>.new Predicate<Relationship> with item -> {Path extendedPath=extend(path,item); in method package doExpand(path Path, state BranchState) : Iterator<Relationship> from class org.neo4j.kernel.StandardExpander.FilteringExpander


    private static Map<Direction, Collection<RelationshipType>> temporaryTypeMap()
    {
        Map<Direction, Collection<RelationshipType>> map = new EnumMap<Direction,
                Collection<RelationshipType>>( Direction.class );
        for ( Direction direction : Direction.values() )
        {
            map.put( direction, new ArrayList<>() );
        }
        return map;
    }

    private static Map<Direction, Collection<RelationshipType>> temporaryTypeMap()
    {
        Map<Direction, Collection<RelationshipType>> map = new EnumMap<Direction,
                Collection<RelationshipType>>( Direction.class );
        for ( Direction direction : Direction.values() )
        {
            map.put( direction, new ArrayList<RelationshipType>() );
        }
        return map;
    }

Replace Generic With Diamond ArrayList<RelationshipType> with ArrayList<> in method private temporaryTypeMap() : Map<Direction,Collection<RelationshipType>> from class org.neo4j.kernel.StandardExpander


    public RestartOnChange( final String configurationNamePrefix, Lifecycle life )
    {
        this( item -> {
            return item.startsWith( configurationNamePrefix );
        }, life );
    }

    public RestartOnChange( final String configurationNamePrefix, Lifecycle life )
    {
        this( new Predicate<String>()
        {
            @Override
            public boolean test( String item )
            {
                return item.startsWith( configurationNamePrefix );
            }
        }, life );
    }

Replace Anonymous With Lambda org.neo4j.kernel.configuration.RestartOnChange.RestartOnChange.new Predicate<String> with item -> {return item.startsWith(configurationNamePrefix); in method public RestartOnChange(configurationNamePrefix String, life Lifecycle) from class org.neo4j.kernel.configuration.RestartOnChange


        @SafeVarargs
        public static <R extends AbstractBaseRecord> Iterable<R> scan( final RecordStore<R> store,
                final boolean forward, final Predicate<? super R>... filters )
        {
            return () -> new PrefetchingIterator<R>()
            {
                final PrimitiveLongIterator ids = new StoreIdIterator( store, forward );

                @Override
                protected R fetchNextOrNull()
                {
                    scan:
                    while ( ids.hasNext() )
                    {
                        R record = store.forceGetRecord( ids.next() );
                        for ( Predicate<? super R> filter : filters )
                        {
                            if ( !filter.test( record ) )
                            {
                                continue scan;
                            }
                        }
                        return record;
                    }
                    return null;
                }
            };
        }

        @SafeVarargs
        public static <R extends AbstractBaseRecord> Iterable<R> scan( final RecordStore<R> store,
                final boolean forward, final Predicate<? super R>... filters )
        {
            return new Iterable<R>()
            {
                @Override
                public Iterator<R> iterator()
                {
                    return new PrefetchingIterator<R>()
                    {
                        final PrimitiveLongIterator ids = new StoreIdIterator( store, forward );

                        @Override
                        protected R fetchNextOrNull()
                        {
                            scan:
                            while ( ids.hasNext() )
                            {
                                R record = store.forceGetRecord( ids.next() );
                                for ( Predicate<? super R> filter : filters )
                                {
                                    if ( !filter.test( record ) )
                                    {
                                        continue scan;
                                    }
                                }
                                return record;
                            }
                            return null;
                        }
                    };
                }
            };
        }

Replace Anonymous With Lambda org.neo4j.kernel.impl.store.RecordStore.Scanner.scan.new Iterable<R> with () -> new PrefetchingIterator<R>(){ in method public scan(store RecordStore<R>, forward boolean, filters Predicate<? super R>...) : Iterable<R> from class org.neo4j.kernel.impl.store.RecordStore.Scanner


    private Set<T> newSet()
    {
        return newSetFromMap( new VersionedHashMap<>() );
    }

    private Set<T> newSet()
    {
        return newSetFromMap( new VersionedHashMap<T, Boolean>() );
    }

Replace Generic With Diamond VersionedHashMap<T,Boolean> with VersionedHashMap<> in method private newSet() : Set<T> from class org.neo4j.kernel.impl.util.diffsets.SuperDiffSets


    @Test
    public void shouldNotWriteDebugToInternalDiagnosticsLogByDefault() throws Exception
    {
        // Given
        GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabase( testDir.graphDbDir() );

        // When
        LogService logService = ((GraphDatabaseAPI) db).getDependencyResolver().resolveDependency( LogService.class );
        logService.getInternalLog( getClass() ).debug( "A debug entry" );

        db.shutdown();
        final File internalLog = new File( testDir.graphDbDir(), StoreLogService.INTERNAL_LOG_NAME );

        // Then
        assertThat( internalLog.isFile(), is( true ) );
        assertThat( internalLog.length(), greaterThan( 0L ) );

        assertThat( IteratorUtil.count( asIterable( internalLog, StandardCharsets.UTF_8 ), line -> {
            return line.contains( "A debug entry" );
        } ), is( 0 ) );
    }

    @Test
    public void shouldNotWriteDebugToInternalDiagnosticsLogByDefault() throws Exception
    {
        // Given
        GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabase( testDir.graphDbDir() );

        // When
        LogService logService = ((GraphDatabaseAPI) db).getDependencyResolver().resolveDependency( LogService.class );
        logService.getInternalLog( getClass() ).debug( "A debug entry" );

        db.shutdown();
        final File internalLog = new File( testDir.graphDbDir(), StoreLogService.INTERNAL_LOG_NAME );

        // Then
        assertThat( internalLog.isFile(), is( true ) );
        assertThat( internalLog.length(), greaterThan( 0L ) );

        assertThat( IteratorUtil.count( asIterable( internalLog, StandardCharsets.UTF_8 ), new Predicate<String>()
        {
            @Override
            public boolean test( String line )
            {
                return line.contains( "A debug entry" );
            }
        } ), is( 0 ) );
    }

Replace Anonymous With Lambda org.neo4j.graphdb.GraphDatabaseInternalLogIT.shouldNotWriteDebugToInternalDiagnosticsLogByDefault.assertThat.count.new Predicate<String> with line -> {return line.contains("A debug entry"); in method public shouldNotWriteDebugToInternalDiagnosticsLogByDefault() : void from class org.neo4j.graphdb.GraphDatabaseInternalLogIT


    @Test
    public void shouldNotEmptyQueueConcurrently()
    {
        // given
        final AtomicInteger totalCount = new AtomicInteger( 0 );
        final AtomicInteger concurrentCount = new AtomicInteger( 0 );
        final DoubleLatch jobLatch = new DoubleLatch();
        final DoubleLatch testLatch = new DoubleLatch();
        final ThreadLocal<Boolean> hasRun = new ThreadLocal<Boolean>() {
            @Override
            protected Boolean initialValue()
            {
                return false;
            }
        };

        IndexSamplingJobFactory jobFactory = proxy -> {
            // make sure we execute this once per thread
            if ( hasRun.get() )
            {
                return null;
            }
            hasRun.set( true );

            if ( !concurrentCount.compareAndSet( 0, 1 ) )
            {
                throw new IllegalStateException( "count !== 0 on create" );
            }
            totalCount.incrementAndGet();

            jobLatch.awaitStart();
            testLatch.start();
            jobLatch.awaitFinish();

            concurrentCount.decrementAndGet();

            testLatch.finish();
            return null;
        };

        final IndexSamplingController controller = new IndexSamplingController(
                samplingConfig, jobFactory, jobQueue, tracker, snapshotProvider, scheduler, FALSE
        );
        when( tracker.canExecuteMoreSamplingJobs() ).thenReturn( true );
        when( indexProxy.getState() ).thenReturn( ONLINE );

        // when running once
        new Thread( runController( controller, BACKGROUND_REBUILD_UPDATED ) ).start();

        jobLatch.start();
        testLatch.awaitStart();

        // then blocking on first job
        assertEquals( 1, concurrentCount.get() );
        assertEquals( 1, totalCount.get() );

        // when running a second time
        controller.sampleIndexes( BACKGROUND_REBUILD_UPDATED );

        // then no concurrent job execution
        jobLatch.finish();
        testLatch.awaitFinish();

        // and finally exactly one job has run to completion
        assertEquals( 0, concurrentCount.get() );
        assertEquals( 1, totalCount.get() );
    }

    @Test
    public void shouldNotEmptyQueueConcurrently()
    {
        // given
        final AtomicInteger totalCount = new AtomicInteger( 0 );
        final AtomicInteger concurrentCount = new AtomicInteger( 0 );
        final DoubleLatch jobLatch = new DoubleLatch();
        final DoubleLatch testLatch = new DoubleLatch();
        final ThreadLocal<Boolean> hasRun = new ThreadLocal<Boolean>() {
            @Override
            protected Boolean initialValue()
            {
                return false;
            }
        };

        IndexSamplingJobFactory jobFactory = new IndexSamplingJobFactory()
        {
            @Override
            public IndexSamplingJob create( IndexProxy indexProxy )
            {
                // make sure we execute this once per thread
                if ( hasRun.get() )
                {
                    return null;
                }
                hasRun.set( true );

                if ( !concurrentCount.compareAndSet( 0, 1 ) )
                {
                    throw new IllegalStateException( "count !== 0 on create" );
                }
                totalCount.incrementAndGet();

                jobLatch.awaitStart();
                testLatch.start();
                jobLatch.awaitFinish();

                concurrentCount.decrementAndGet();

                testLatch.finish();
                return null;
            }
        };

        final IndexSamplingController controller = new IndexSamplingController(
                samplingConfig, jobFactory, jobQueue, tracker, snapshotProvider, scheduler, FALSE
        );
        when( tracker.canExecuteMoreSamplingJobs() ).thenReturn( true );
        when( indexProxy.getState() ).thenReturn( ONLINE );

        // when running once
        new Thread( runController( controller, BACKGROUND_REBUILD_UPDATED ) ).start();

        jobLatch.start();
        testLatch.awaitStart();

        // then blocking on first job
        assertEquals( 1, concurrentCount.get() );
        assertEquals( 1, totalCount.get() );

        // when running a second time
        controller.sampleIndexes( BACKGROUND_REBUILD_UPDATED );

        // then no concurrent job execution
        jobLatch.finish();
        testLatch.awaitFinish();

        // and finally exactly one job has run to completion
        assertEquals( 0, concurrentCount.get() );
        assertEquals( 1, totalCount.get() );
    }

Replace Anonymous With Lambda org.neo4j.kernel.impl.api.index.sampling.IndexSamplingControllerTest.shouldNotEmptyQueueConcurrently.jobFactory.new IndexSamplingJobFactory with proxy -> {if(hasRun.get()){return null; in method public shouldNotEmptyQueueConcurrently() : void from class org.neo4j.kernel.impl.api.index.sampling.IndexSamplingControllerTest


    @Test
    public void shouldNotStartOtherSamplingWhenSamplingAllTheIndexes()
    {
        // given
        final AtomicInteger totalCount = new AtomicInteger( 0 );
        final AtomicInteger concurrentCount = new AtomicInteger( 0 );
        final DoubleLatch jobLatch = new DoubleLatch();
        final DoubleLatch testLatch = new DoubleLatch();

        IndexSamplingJobFactory jobFactory = proxy -> {
            if ( ! concurrentCount.compareAndSet( 0, 1 ) )
            {
                throw new IllegalStateException( "count !== 0 on create" );
            }
            totalCount.incrementAndGet();
            jobLatch.awaitStart();
            testLatch.start();
            jobLatch.awaitFinish();
            concurrentCount.decrementAndGet();
            testLatch.finish();
            return null;
        };

        final IndexSamplingController controller = new IndexSamplingController(
                samplingConfig, jobFactory, jobQueue, tracker, snapshotProvider, scheduler, TRUE
        );
        when( tracker.canExecuteMoreSamplingJobs() ).thenReturn( true );
        when( indexProxy.getState() ).thenReturn( ONLINE );

        // when running once
        new Thread( runController( controller, TRIGGER_REBUILD_UPDATED ) ).start();

        jobLatch.start();
        testLatch.awaitStart();

        // then blocking on first job
        assertEquals( 1, concurrentCount.get() );

        // when running a second time
        controller.sampleIndexes( BACKGROUND_REBUILD_UPDATED );

        // then no concurrent job execution
        jobLatch.finish();
        testLatch.awaitFinish();

        // and finally exactly one job has run to completion
        assertEquals( 0, concurrentCount.get() );
        assertEquals( 1, totalCount.get() );
    }

    @Test
    public void shouldNotStartOtherSamplingWhenSamplingAllTheIndexes()
    {
        // given
        final AtomicInteger totalCount = new AtomicInteger( 0 );
        final AtomicInteger concurrentCount = new AtomicInteger( 0 );
        final DoubleLatch jobLatch = new DoubleLatch();
        final DoubleLatch testLatch = new DoubleLatch();

        IndexSamplingJobFactory jobFactory = new IndexSamplingJobFactory()
        {
            @Override
            public IndexSamplingJob create( IndexProxy indexProxy )
            {
                if ( ! concurrentCount.compareAndSet( 0, 1 ) )
                {
                    throw new IllegalStateException( "count !== 0 on create" );
                }
                totalCount.incrementAndGet();
                jobLatch.awaitStart();
                testLatch.start();
                jobLatch.awaitFinish();
                concurrentCount.decrementAndGet();
                testLatch.finish();
                return null;
            }
        };

        final IndexSamplingController controller = new IndexSamplingController(
                samplingConfig, jobFactory, jobQueue, tracker, snapshotProvider, scheduler, TRUE
        );
        when( tracker.canExecuteMoreSamplingJobs() ).thenReturn( true );
        when( indexProxy.getState() ).thenReturn( ONLINE );

        // when running once
        new Thread( runController( controller, TRIGGER_REBUILD_UPDATED ) ).start();

        jobLatch.start();
        testLatch.awaitStart();

        // then blocking on first job
        assertEquals( 1, concurrentCount.get() );

        // when running a second time
        controller.sampleIndexes( BACKGROUND_REBUILD_UPDATED );

        // then no concurrent job execution
        jobLatch.finish();
        testLatch.awaitFinish();

        // and finally exactly one job has run to completion
        assertEquals( 0, concurrentCount.get() );
        assertEquals( 1, totalCount.get() );
    }

Replace Anonymous With Lambda org.neo4j.kernel.impl.api.index.sampling.IndexSamplingControllerTest.shouldNotStartOtherSamplingWhenSamplingAllTheIndexes.jobFactory.new IndexSamplingJobFactory with proxy -> {if(!concurrentCount.compareAndSet(0,1)){throw new IllegalStateException("count !== 0 on create"); in method public shouldNotStartOtherSamplingWhenSamplingAllTheIndexes() : void from class org.neo4j.kernel.impl.api.index.sampling.IndexSamplingControllerTest


    @Test
    @Resources.Life(STARTED)
    public void shouldSupportTransactionsAppliedOutOfOrderOnRotation() throws Exception
    {
        // given
        final CountsTracker tracker = resourceManager.managed( newTracker() );
        try ( CountsAccessor.Updater tx = tracker.apply( 2 ).get() )
        {
            tx.incrementNodeCount( 1, 1 );
        }
        try ( CountsAccessor.Updater tx = tracker.apply( 4 ).get() )
        {
            tx.incrementNodeCount( 1, 1 );
        }

        // when
        Future<Long> rotated = threading.executeAndAwait( new Rotation( 2 ), tracker, thread -> {
            switch ( thread.getState() )
            {
            case BLOCKED:
            case WAITING:
            case TIMED_WAITING:
            case TERMINATED:
                return true;
            default:
                return false;
            }
        }, 10, SECONDS );
        try ( CountsAccessor.Updater tx = tracker.apply( 5 ).get() )
        {
            tx.incrementNodeCount( 1, 1 );
        }
        try ( CountsAccessor.Updater tx = tracker.apply( 3 ).get() )
        {
            tx.incrementNodeCount( 1, 1 );
        }

        // then
        assertEquals( "rotated transaction", 4, rotated.get().longValue() );
        assertEquals( "stored transaction", 4, tracker.txId() );

        // the value in memory
        assertEquals( "count", 4, tracker.nodeCount( 1, Registers.newDoubleLongRegister() ).readSecond() );

        // the value in the store
        CountsVisitor visitor = mock( CountsVisitor.class );
        tracker.visitFile( tracker.currentFile(), visitor );
        verify( visitor ).visitNodeCount( 1, 3 );
        verifyNoMoreInteractions( visitor );

        assertEquals( "final rotation", 5, tracker.rotate( 5 ) );
    }

    @Test
    @Resources.Life(STARTED)
    public void shouldSupportTransactionsAppliedOutOfOrderOnRotation() throws Exception
    {
        // given
        final CountsTracker tracker = resourceManager.managed( newTracker() );
        try ( CountsAccessor.Updater tx = tracker.apply( 2 ).get() )
        {
            tx.incrementNodeCount( 1, 1 );
        }
        try ( CountsAccessor.Updater tx = tracker.apply( 4 ).get() )
        {
            tx.incrementNodeCount( 1, 1 );
        }

        // when
        Future<Long> rotated = threading.executeAndAwait( new Rotation( 2 ), tracker, new Predicate<Thread>()
        {
            @Override
            public boolean test( Thread thread )
            {
                switch ( thread.getState() )
                {
                case BLOCKED:
                case WAITING:
                case TIMED_WAITING:
                case TERMINATED:
                    return true;
                default:
                    return false;
                }
            }
        }, 10, SECONDS );
        try ( CountsAccessor.Updater tx = tracker.apply( 5 ).get() )
        {
            tx.incrementNodeCount( 1, 1 );
        }
        try ( CountsAccessor.Updater tx = tracker.apply( 3 ).get() )
        {
            tx.incrementNodeCount( 1, 1 );
        }

        // then
        assertEquals( "rotated transaction", 4, rotated.get().longValue() );
        assertEquals( "stored transaction", 4, tracker.txId() );

        // the value in memory
        assertEquals( "count", 4, tracker.nodeCount( 1, Registers.newDoubleLongRegister() ).readSecond() );

        // the value in the store
        CountsVisitor visitor = mock( CountsVisitor.class );
        tracker.visitFile( tracker.currentFile(), visitor );
        verify( visitor ).visitNodeCount( 1, 3 );
        verifyNoMoreInteractions( visitor );

        assertEquals( "final rotation", 5, tracker.rotate( 5 ) );
    }

Replace Anonymous With Lambda org.neo4j.kernel.impl.store.counts.CountsTrackerTest.shouldSupportTransactionsAppliedOutOfOrderOnRotation.rotated.executeAndAwait.new Predicate<Thread> with thread -> {switch(thread.getState())case BLOCKED:case WAITING:case TIMED_WAITING:case TERMINATED:return true; in method public shouldSupportTransactionsAppliedOutOfOrderOnRotation() : void from class org.neo4j.kernel.impl.store.counts.CountsTrackerTest


    @Test
    @Resources.Life( STARTED )
    public void shouldBlockRotationUntilRequestedTransactionsAreApplied() throws Exception
    {
        // given
        final Store store = resourceManager.managed( createTestStore() );

        // when
        updateStore( store, 1 );
        Future<Long> rotation = threading.executeAndAwait( store.rotation, 3l, thread -> {
            switch ( thread.getState() )
            {
            case BLOCKED:
            case WAITING:
            case TIMED_WAITING:
            case TERMINATED:
                return true;
            default:
                return false;
            }
        }, 100, SECONDS );
        // rotation should wait...
        assertFalse( rotation.isDone() );
        SECONDS.sleep( 1 );
        assertFalse( rotation.isDone() );
        // apply update
        updateStore( store, 3 );
        // rotation should still wait...
        assertFalse( rotation.isDone() );
        SECONDS.sleep( 1 );
        assertFalse( rotation.isDone() );
        // apply update
        updateStore( store, 4 );
        // rotation should still wait...
        assertFalse( rotation.isDone() );
        SECONDS.sleep( 1 );
        assertFalse( rotation.isDone() );
        // apply update
        updateStore( store, 2 );

        // then
        assertEquals( 3, rotation.get().longValue() );
        assertEquals( 3, store.headers().get( TX_ID ).longValue() );
        store.rotation.apply( 4l );
    }

    @Test
    @Resources.Life( STARTED )
    public void shouldBlockRotationUntilRequestedTransactionsAreApplied() throws Exception
    {
        // given
        final Store store = resourceManager.managed( createTestStore() );

        // when
        updateStore( store, 1 );
        Future<Long> rotation = threading.executeAndAwait( store.rotation, 3l, new Predicate<Thread>()
        {
            @Override
            public boolean test( Thread thread )
            {
                switch ( thread.getState() )
                {
                case BLOCKED:
                case WAITING:
                case TIMED_WAITING:
                case TERMINATED:
                    return true;
                default:
                    return false;
                }
            }
        }, 100, SECONDS );
        // rotation should wait...
        assertFalse( rotation.isDone() );
        SECONDS.sleep( 1 );
        assertFalse( rotation.isDone() );
        // apply update
        updateStore( store, 3 );
        // rotation should still wait...
        assertFalse( rotation.isDone() );
        SECONDS.sleep( 1 );
        assertFalse( rotation.isDone() );
        // apply update
        updateStore( store, 4 );
        // rotation should still wait...
        assertFalse( rotation.isDone() );
        SECONDS.sleep( 1 );
        assertFalse( rotation.isDone() );
        // apply update
        updateStore( store, 2 );

        // then
        assertEquals( 3, rotation.get().longValue() );
        assertEquals( 3, store.headers().get( TX_ID ).longValue() );
        store.rotation.apply( 4l );
    }

Replace Anonymous With Lambda org.neo4j.kernel.impl.store.kvstore.AbstractKeyValueStoreTest.shouldBlockRotationUntilRequestedTransactionsAreApplied.rotation.executeAndAwait.new Predicate<Thread> with thread -> {switch(thread.getState())case BLOCKED:case WAITING:case TIMED_WAITING:case TERMINATED:return true; in method public shouldBlockRotationUntilRequestedTransactionsAreApplied() : void from class org.neo4j.kernel.impl.store.kvstore.AbstractKeyValueStoreTest


    private void updateStore( final Store store, long transaction ) throws IOException
    {
        ThrowingConsumer<Long,IOException> update = u -> {
            try ( EntryUpdater<String> updater = store.updater( u ).get() )
            {
                updater.apply( "key " + u, store.value( "value " + u ) );
            }
        };
        update.accept( transaction );
    }

    private void updateStore( final Store store, long transaction ) throws IOException
    {
        ThrowingConsumer<Long,IOException> update = new ThrowingConsumer<Long,IOException>()
        {
            @Override
            public void accept( Long update ) throws IOException
            {
                try ( EntryUpdater<String> updater = store.updater( update ).get() )
                {
                    updater.apply( "key " + update, store.value( "value " + update ) );
                }
            }
        };
        update.accept( transaction );
    }

Replace Anonymous With Lambda org.neo4j.kernel.impl.store.kvstore.AbstractKeyValueStoreTest.updateStore.update.new ThrowingConsumer<Long,IOException> with u -> {try(EntryUpdater<String> updater=store.updater(u).get())updater.apply("key " + u,store.value("value " + u)); in method private updateStore(store Store, transaction long) : void from class org.neo4j.kernel.impl.store.kvstore.AbstractKeyValueStoreTest


    public <R> Future<R> executeDontWait( final WorkerCommand<T, R> cmd )
    {
        lastExecutionTrigger = new Exception();
        executionState = ExecutionState.REQUESTED_EXECUTION;
        return commandExecutor.submit( () -> {
            executionState = ExecutionState.EXECUTING;
            try
            {
                return cmd.doWork( state );
            }
            finally
            {
                executionState = ExecutionState.EXECUTED;
            }
        } );
    }

    public <R> Future<R> executeDontWait( final WorkerCommand<T, R> cmd )
    {
        lastExecutionTrigger = new Exception();
        executionState = ExecutionState.REQUESTED_EXECUTION;
        return commandExecutor.submit( new Callable<R>()
        {
            @Override
            public R call() throws Exception
            {
                executionState = ExecutionState.EXECUTING;
                try
                {
                    return cmd.doWork( state );
                }
                finally
                {
                    executionState = ExecutionState.EXECUTED;
                }
            }
        } );
    }

Replace Anonymous With Lambda org.neo4j.test.OtherThreadExecutor.executeDontWait.submit.new Callable<R> with () -> {executionState=ExecutionState.EXECUTING; in method public executeDontWait(cmd WorkerCommand<T,R>) : Future<R> from class org.neo4j.test.OtherThreadExecutor


    private static <FROM, TO, EX extends Exception> Callable<TO> task(
            final Barrier barrier, final ThrowingFunction<FROM,TO,EX> function, final FROM parameter,
            final Consumer<Thread> threadConsumer )
    {
        return () -> {
            Thread thread = Thread.currentThread();
            String name = thread.getName();
            thread.setName( function.toString() );
            threadConsumer.accept( thread );
            barrier.reached();
            try
            {
                return function.apply( parameter );
            }
            finally
            {
                thread.setName( name );
            }
        };
    }

    private static <FROM, TO, EX extends Exception> Callable<TO> task(
            final Barrier barrier, final ThrowingFunction<FROM,TO,EX> function, final FROM parameter,
            final Consumer<Thread> threadConsumer )
    {
        return new Callable<TO>()
        {
            @Override
            public TO call() throws Exception
            {
                Thread thread = Thread.currentThread();
                String name = thread.getName();
                thread.setName( function.toString() );
                threadConsumer.accept( thread );
                barrier.reached();
                try
                {
                    return function.apply( parameter );
                }
                finally
                {
                    thread.setName( name );
                }
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.test.ThreadingRule.task.new Callable<TO> with () -> {Thread thread=Thread.currentThread(); in method private task(barrier Barrier, function ThrowingFunction<FROM,TO,EX>, parameter FROM, threadConsumer Consumer<Thread>) : Callable<TO> from class org.neo4j.test.ThreadingRule


    @Test
    public void indexCreationConfigRaceCondition() throws Exception
    {
        // Since this is a probability test and not a precise test run do the run
        // a couple of times to be sure.
        for ( int run = 0; run < 10; run++ )
        {
            final int r = run;
            final CountDownLatch latch = new CountDownLatch( 1 );
            ExecutorService executor = newCachedThreadPool();
            for ( int thread = 0; thread < 10; thread++ )
            {
                executor.submit( (Runnable) () -> {
                    try ( Transaction tx = db.beginTx() )
                    {
                        latch.await();
                        Index<Node> index = db.index().forNodes( "index" + r );
                        Node node = db.createNode();
                        index.add( node, "name", "Name" );
                        tx.success();
                    }
                    catch ( InterruptedException e )
                    {
                        Thread.interrupted();
                    }
                } );
            }
            latch.countDown();
            executor.shutdown();
            executor.awaitTermination( 10, TimeUnit.SECONDS );

            verifyThatIndexCreationTransactionIsTheFirstOne();
        }
    }

    @Test
    public void indexCreationConfigRaceCondition() throws Exception
    {
        // Since this is a probability test and not a precise test run do the run
        // a couple of times to be sure.
        for ( int run = 0; run < 10; run++ )
        {
            final int r = run;
            final CountDownLatch latch = new CountDownLatch( 1 );
            ExecutorService executor = newCachedThreadPool();
            for ( int thread = 0; thread < 10; thread++ )
            {
                executor.submit( new Runnable()
                {
                    @Override
                    public void run()
                    {
                        try ( Transaction tx = db.beginTx() )
                        {
                            latch.await();
                            Index<Node> index = db.index().forNodes( "index" + r );
                            Node node = db.createNode();
                            index.add( node, "name", "Name" );
                            tx.success();
                        }
                        catch ( InterruptedException e )
                        {
                            Thread.interrupted();
                        }
                    }
                } );
            }
            latch.countDown();
            executor.shutdown();
            executor.awaitTermination( 10, TimeUnit.SECONDS );

            verifyThatIndexCreationTransactionIsTheFirstOne();
        }
    }

Replace Anonymous With Lambda org.neo4j.index.impl.lucene.legacy.IndexCreationTest.indexCreationConfigRaceCondition.submit.new Runnable with () -> {try(Transaction tx=db.beginTx())latch.await(); in method public indexCreationConfigRaceCondition() : void from class org.neo4j.index.impl.lucene.legacy.IndexCreationTest


    public void rollbackSuspendedTransactionsIdleSince( final long oldestLastActiveTime )
    {
        rollbackSuspended( item -> {
            try
            {
                SuspendedTransaction transaction = item.getSuspendedTransaction();
                return transaction.lastActiveTimestamp < oldestLastActiveTime;
            }
            catch ( InvalidConcurrentTransactionAccess concurrentTransactionAccessError )
            {
                throw new RuntimeException( concurrentTransactionAccessError );
            }
        } );
    }

    public void rollbackSuspendedTransactionsIdleSince( final long oldestLastActiveTime )
    {
        rollbackSuspended( new Predicate<TransactionMarker>()
        {
            @Override
            public boolean test( TransactionMarker item )
            {
                try
                {
                    SuspendedTransaction transaction = item.getSuspendedTransaction();
                    return transaction.lastActiveTimestamp < oldestLastActiveTime;
                }
                catch ( InvalidConcurrentTransactionAccess concurrentTransactionAccessError )
                {
                    throw new RuntimeException( concurrentTransactionAccessError );
                }
            }
        } );
    }

Replace Anonymous With Lambda org.neo4j.server.rest.transactional.TransactionHandleRegistry.rollbackSuspendedTransactionsIdleSince.rollbackSuspended.new Predicate<TransactionMarker> with item -> {trySuspendedTransaction transaction=item.getSuspendedTransaction(); in method public rollbackSuspendedTransactionsIdleSince(oldestLastActiveTime long) : void from class org.neo4j.server.rest.transactional.TransactionHandleRegistry


    private Iterable<ConstraintDefinition> filteredNodeConstraints( String labelName, final ConstraintType type )
    {
        return filter( item -> {
            return item.isConstraintType( type );
        }, graphDb.schema().getConstraints( label( labelName ) ) );
    }

    private Iterable<ConstraintDefinition> filteredNodeConstraints( String labelName, final ConstraintType type )
    {
        return filter( new Predicate<ConstraintDefinition>()
        {
            @Override
            public boolean test( ConstraintDefinition item )
            {
                return item.isConstraintType( type );
            }
        }, graphDb.schema().getConstraints( label( labelName ) ) );
    }

Replace Anonymous With Lambda org.neo4j.server.rest.web.DatabaseActions.filteredNodeConstraints.filter.new Predicate<ConstraintDefinition> with item -> {return item.isConstraintType(type); in method private filteredNodeConstraints(labelName String, type ConstraintType) : Iterable<ConstraintDefinition> from class org.neo4j.server.rest.web.DatabaseActions


    private Iterable<ConstraintDefinition> filteredRelationshipConstraints( String typeName, final ConstraintType type )
    {
        return filter( item -> {
            return item.isConstraintType( type );
        }, graphDb.schema().getConstraints( RelationshipType.withName( typeName ) ) );
    }

    private Iterable<ConstraintDefinition> filteredRelationshipConstraints( String typeName, final ConstraintType type )
    {
        return filter( new Predicate<ConstraintDefinition>()
        {
            @Override
            public boolean test( ConstraintDefinition item )
            {
                return item.isConstraintType( type );
            }
        }, graphDb.schema().getConstraints( RelationshipType.withName( typeName ) ) );
    }

Replace Anonymous With Lambda org.neo4j.server.rest.web.DatabaseActions.filteredRelationshipConstraints.filter.new Predicate<ConstraintDefinition> with item -> {return item.isConstraintType(type); in method private filteredRelationshipConstraints(typeName String, type ConstraintType) : Iterable<ConstraintDefinition> from class org.neo4j.server.rest.web.DatabaseActions


    public Iterable<ConstraintDefinition> getPropertyUniquenessConstraints( String labelName, final String propertyKey )
    {
        try ( Transaction tx = database.getGraph().beginTx() )
        {
            Iterable<ConstraintDefinition> definitions = Iterables.filter( item -> {
                if ( item.isConstraintType( ConstraintType.UNIQUENESS ) )
                {
                    Iterable<String> keys = item.getPropertyKeys();
                    return single( keys ).equals( propertyKey );
                }
                else
                {
                    return false;
                }

            }, database.getGraph().schema().getConstraints( label( labelName ) ) );
            tx.success();
            return definitions;
        }
    }

    public Iterable<ConstraintDefinition> getPropertyUniquenessConstraints( String labelName, final String propertyKey )
    {
        try ( Transaction tx = database.getGraph().beginTx() )
        {
            Iterable<ConstraintDefinition> definitions = Iterables.filter( new Predicate<ConstraintDefinition>()
            {

                @Override
                public boolean test( ConstraintDefinition item )
                {
                    if ( item.isConstraintType( ConstraintType.UNIQUENESS ) )
                    {
                        Iterable<String> keys = item.getPropertyKeys();
                        return single( keys ).equals( propertyKey );
                    }
                    else
                    {
                        return false;
                    }

                }
            }, database.getGraph().schema().getConstraints( label( labelName ) ) );
            tx.success();
            return definitions;
        }
    }

Replace Anonymous With Lambda org.neo4j.server.rest.domain.GraphDbHelper.getPropertyUniquenessConstraints.definitions.filter.new Predicate<ConstraintDefinition> with item -> {if(item.isConstraintType(ConstraintType.UNIQUENESS)){Iterable<String> keys=item.getPropertyKeys(); in method public getPropertyUniquenessConstraints(labelName String, propertyKey String) : Iterable<ConstraintDefinition> from class org.neo4j.server.rest.domain.GraphDbHelper


    private static Iterable<ConstraintDefinition> filterByConstraintTypeAndPropertyKey(
            Iterable<ConstraintDefinition> definitions, final ConstraintType type, final String propertyKey )
    {
        return Iterables.filter( definition -> {
            if ( definition.isConstraintType( type ) )
            {
                Iterable<String> keys = definition.getPropertyKeys();
                return single( keys ).equals( propertyKey );
            }
            return false;
        }, definitions );
    }

    private static Iterable<ConstraintDefinition> filterByConstraintTypeAndPropertyKey(
            Iterable<ConstraintDefinition> definitions, final ConstraintType type, final String propertyKey )
    {
        return Iterables.filter( new Predicate<ConstraintDefinition>()
        {
            @Override
            public boolean test( ConstraintDefinition definition )
            {
                if ( definition.isConstraintType( type ) )
                {
                    Iterable<String> keys = definition.getPropertyKeys();
                    return single( keys ).equals( propertyKey );
                }
                return false;
            }
        }, definitions );
    }

Replace Anonymous With Lambda org.neo4j.server.rest.domain.GraphDbHelper.filterByConstraintTypeAndPropertyKey.filter.new Predicate<ConstraintDefinition> with definition -> {if(definition.isConstraintType(type)){Iterable<String> keys=definition.getPropertyKeys(); in method private filterByConstraintTypeAndPropertyKey(definitions Iterable<ConstraintDefinition>, type ConstraintType, propertyKey String) : Iterable<ConstraintDefinition> from class org.neo4j.server.rest.domain.GraphDbHelper


    private Iterable<IndexDefinition> indexesByLabel( org.neo4j.graphdb.schema.Schema schema, Label[] labels )
    {
        Iterable<IndexDefinition> indexes = schema.getIndexes();
        for ( final Label label : labels )
        {
            indexes = filter( item -> {
                return item.getLabel().name().equals( label.name() );
            }, indexes );
        }
        return indexes;
    }

    private Iterable<IndexDefinition> indexesByLabel( org.neo4j.graphdb.schema.Schema schema, Label[] labels )
    {
        Iterable<IndexDefinition> indexes = schema.getIndexes();
        for ( final Label label : labels )
        {
            indexes = filter( new Predicate<IndexDefinition>()
            {
                @Override
                public boolean test( IndexDefinition item )
                {
                    return item.getLabel().name().equals( label.name() );
                }
            }, indexes );
        }
        return indexes;
    }

Replace Anonymous With Lambda org.neo4j.shell.kernel.apps.Schema.indexesByLabel.filter.new Predicate<IndexDefinition> with item -> {return item.getLabel().name().equals(label.name()); in method private indexesByLabel(schema Schema, labels Label[]) : Iterable<IndexDefinition> from class org.neo4j.shell.kernel.apps.Schema


        public void unavailableMember( final URI member, final InstanceId id, final String role )
        {
            availableMembers = toList( filter( item -> {
                boolean matchByUriOrId = item.getClusterUri().equals( member ) || item.getInstanceId().equals( id );
                boolean matchByRole = item.getRole().equals( role );

                return !(matchByUriOrId && matchByRole);
            }, availableMembers ) );
        }

        public void unavailableMember( final URI member, final InstanceId id, final String role )
        {
            availableMembers = toList( filter( new Predicate<MemberIsAvailable>()
            {
                @Override
                public boolean test( MemberIsAvailable item )
                {
                    boolean matchByUriOrId = item.getClusterUri().equals( member ) || item.getInstanceId().equals( id );
                    boolean matchByRole = item.getRole().equals( role );

                    return !(matchByUriOrId && matchByRole);
                }
            }, availableMembers ) );
        }

Replace Anonymous With Lambda org.neo4j.cluster.member.paxos.PaxosClusterMemberEvents.ClusterMembersSnapshot.unavailableMember.toList.filter.new Predicate<MemberIsAvailable> with item -> {boolean matchByUriOrId=item.getClusterUri().equals(member) || item.getInstanceId().equals(id); in method public unavailableMember(member URI, id InstanceId, role String) : void from class org.neo4j.cluster.member.paxos.PaxosClusterMemberEvents.ClusterMembersSnapshot


        public Iterable<MemberIsAvailable> getCurrentAvailable( final InstanceId memberId )
        {
            return toList( Iterables.filter( item -> {
                return item.getInstanceId().equals( memberId );
            }, availableMembers ) );
        }

        public Iterable<MemberIsAvailable> getCurrentAvailable( final InstanceId memberId )
        {
            return toList( Iterables.filter( new Predicate<MemberIsAvailable>()
            {
                @Override
                public boolean test( MemberIsAvailable item )
                {
                    return item.getInstanceId().equals( memberId );
                }
            }, availableMembers ) );
        }

Replace Anonymous With Lambda org.neo4j.cluster.member.paxos.PaxosClusterMemberEvents.ClusterMembersSnapshot.getCurrentAvailable.toList.filter.new Predicate<MemberIsAvailable> with item -> {return item.getInstanceId().equals(memberId); in method public getCurrentAvailable(memberId InstanceId) : Iterable<MemberIsAvailable> from class org.neo4j.cluster.member.paxos.PaxosClusterMemberEvents.ClusterMembersSnapshot


        @Override
        public void leftCluster( final InstanceId instanceId, URI member )
        {
            // Notify unavailability of members
            Listeners.notifyListeners( listeners, listener -> {
                for ( MemberIsAvailable memberIsAvailable : clusterMembersSnapshot.getCurrentAvailable( instanceId ) )
                {
                    listener.memberIsUnavailable( memberIsAvailable.getRole(), instanceId );
                }
            } );

            clusterMembersSnapshot.unavailableMember( instanceId );
        }

        @Override
        public void leftCluster( final InstanceId instanceId, URI member )
        {
            // Notify unavailability of members
            Listeners.notifyListeners( listeners, new Listeners.Notification<ClusterMemberListener>()
            {
                @Override
                public void notify( ClusterMemberListener listener )
                {
                    for ( MemberIsAvailable memberIsAvailable : clusterMembersSnapshot.getCurrentAvailable(
                            instanceId ) )
                    {
                        listener.memberIsUnavailable( memberIsAvailable.getRole(), instanceId );
                    }
                }
            } );

            clusterMembersSnapshot.unavailableMember( instanceId );
        }

Replace Anonymous With Lambda org.neo4j.cluster.member.paxos.PaxosClusterMemberEvents.ClusterListenerImpl.leftCluster.notifyListeners.new Listeners.Notification<ClusterMemberListener> with listener -> {for(MemberIsAvailable memberIsAvailable: clusterMembersSnapshot.getCurrentAvailable(instanceId)){listener.memberIsUnavailable(memberIsAvailable.getRole(),instanceId); in method public leftCluster(instanceId InstanceId, member URI) : void from class org.neo4j.cluster.member.paxos.PaxosClusterMemberEvents.ClusterListenerImpl


    public void joined( InstanceId joinedInstanceId, URI instanceUri )
    {
        if ( instanceUri.equals( members.get( joinedInstanceId ) ) )
        {
            return; // Already know that this node is in - ignore
        }

        this.members = new HashMap<>( members );
        members.put( joinedInstanceId, instanceUri );
    }

    public void joined( InstanceId joinedInstanceId, URI instanceUri )
    {
        if ( instanceUri.equals( members.get( joinedInstanceId ) ) )
        {
            return; // Already know that this node is in - ignore
        }

        this.members = new HashMap<InstanceId, URI>( members );
        members.put( joinedInstanceId, instanceUri );
    }

Replace Generic With Diamond HashMap<InstanceId,URI> with HashMap<> in method public joined(joinedInstanceId InstanceId, instanceUri URI) : void from class org.neo4j.cluster.protocol.cluster.ClusterConfiguration


    public void left( InstanceId leftInstanceId )
    {
        log.info( "Instance " + leftInstanceId + " is leaving the cluster" );
        this.members = new HashMap<>( members );
        members.remove( leftInstanceId );

        // Remove any roles that this node had
        Iterator<Map.Entry<String, InstanceId>> entries = roles.entrySet().iterator();
        while ( entries.hasNext() )
        {
            Map.Entry<String, InstanceId> roleEntry = entries.next();

            if ( roleEntry.getValue().equals( leftInstanceId ) )
            {
                log.info("Removed role " + roleEntry.getValue() + " from leaving instance " + roleEntry.getKey() );
                entries.remove();
            }
        }
    }

    public void left( InstanceId leftInstanceId )
    {
        log.info( "Instance " + leftInstanceId + " is leaving the cluster" );
        this.members = new HashMap<InstanceId, URI>( members );
        members.remove( leftInstanceId );

        // Remove any roles that this node had
        Iterator<Map.Entry<String, InstanceId>> entries = roles.entrySet().iterator();
        while ( entries.hasNext() )
        {
            Map.Entry<String, InstanceId> roleEntry = entries.next();

            if ( roleEntry.getValue().equals( leftInstanceId ) )
            {
                log.info("Removed role " + roleEntry.getValue() + " from leaving instance " + roleEntry.getKey() );
                entries.remove();
            }
        }
    }

Replace Generic With Diamond HashMap<InstanceId,URI> with HashMap<> in method public left(leftInstanceId InstanceId) : void from class org.neo4j.cluster.protocol.cluster.ClusterConfiguration


    public void elected( String name, InstanceId electedInstanceId )
    {
        assert members.containsKey( electedInstanceId );
        roles = new HashMap<>( roles );
        roles.put( name, electedInstanceId );
    }

    public void elected( String name, InstanceId electedInstanceId )
    {
        assert members.containsKey( electedInstanceId );
        roles = new HashMap<String, InstanceId>( roles );
        roles.put( name, electedInstanceId );
    }

Replace Generic With Diamond HashMap<String,InstanceId> with HashMap<> in method public elected(name String, electedInstanceId InstanceId) : void from class org.neo4j.cluster.protocol.cluster.ClusterConfiguration


    public void unelected( String roleName )
    {
        assert roles.containsKey( roleName );
        roles = new HashMap<>( roles );
        roles.remove( roleName );
    }

    public void unelected( String roleName )
    {
        assert roles.containsKey( roleName );
        roles = new HashMap<String, InstanceId>( roles );
        roles.remove( roleName );
    }

Replace Generic With Diamond HashMap<String,InstanceId> with HashMap<> in method public unelected(roleName String) : void from class org.neo4j.cluster.protocol.cluster.ClusterConfiguration


    public void setMembers( Map<InstanceId, URI> members )
    {
        this.members = new HashMap<>( members );
    }

    public void setMembers( Map<InstanceId, URI> members )
    {
        this.members = new HashMap<InstanceId, URI>( members );
    }

Replace Generic With Diamond HashMap<InstanceId,URI> with HashMap<> in method public setMembers(members Map<InstanceId,URI>) : void from class org.neo4j.cluster.protocol.cluster.ClusterConfiguration


    public void setRoles( Map<String, InstanceId> roles )
    {
        for ( InstanceId electedInstanceId : roles.values() )
        {
            assert members.containsKey( electedInstanceId );
        }

        this.roles = new HashMap<>( roles );
    }

    public void setRoles( Map<String, InstanceId> roles )
    {
        for ( InstanceId electedInstanceId : roles.values() )
        {
            assert members.containsKey( electedInstanceId );
        }

        this.roles = new HashMap<String, InstanceId>( roles );
    }

Replace Generic With Diamond HashMap<String,InstanceId> with HashMap<> in method public setRoles(roles Map<String,InstanceId>) : void from class org.neo4j.cluster.protocol.cluster.ClusterConfiguration


    public void removeElected( String roleName )
    {
        roles = new HashMap<>( roles );
        InstanceId removed = roles.remove( roleName );
        log.info( "Removed role " + roleName + " from instance " + removed );
    }

    public void removeElected( String roleName )
    {
        roles = new HashMap<String, InstanceId>( roles );
        InstanceId removed = roles.remove( roleName );
        log.info( "Removed role " + roleName + " from instance " + removed );
    }

Replace Generic With Diamond HashMap<String,InstanceId> with HashMap<> in method public removeElected(roleName String) : void from class org.neo4j.cluster.protocol.cluster.ClusterConfiguration


    public Iterable<String> getRolesOf( final InstanceId node )
    {
        return Iterables.map( new Function<Map.Entry<String, InstanceId>, String>()
        {
            @Override
            public String apply( Map.Entry<String, InstanceId> stringURIEntry )
            {
                return stringURIEntry.getKey();
            }
        }, Iterables.filter( item -> {
            return item.getValue().equals( node );
        }, roles.entrySet() ) );
    }

    public Iterable<String> getRolesOf( final InstanceId node )
    {
        return Iterables.map( new Function<Map.Entry<String, InstanceId>, String>()
        {
            @Override
            public String apply( Map.Entry<String, InstanceId> stringURIEntry )
            {
                return stringURIEntry.getKey();
            }
        }, Iterables.filter( new Predicate<Map.Entry<String, InstanceId>>()
        {
            @Override
            public boolean test( Map.Entry<String, InstanceId> item )
            {
                return item.getValue().equals( node );
            }
        }, roles.entrySet() ) );
    }

Replace Anonymous With Lambda org.neo4j.cluster.protocol.cluster.ClusterConfiguration.getRolesOf.map.filter.new Predicate<Map.Entry<String,InstanceId>> with item -> {return item.getValue().equals(node); in method public getRolesOf(node InstanceId) : Iterable<String> from class org.neo4j.cluster.protocol.cluster.ClusterConfiguration