    /**
     * A wrapper that uses {@link org.neo4j.graphdb.traversal.Paths.DefaultPathDescriptor} to print expanded paths
     * that fulfill {@link BiFunction} predicate using given {@link org.neo4j.graphdb.traversal.Paths.PathDescriptor}.
     * @param source        {@link PathExpander} to wrap.
     * @param pred          {@link BiFunction} used as predicate for printing expansion.
     * @param descriptor    {@link org.neo4j.graphdb.traversal.Paths.PathDescriptor} to use when printing paths.
     * @param out           {@link PrintStream} to use for printing expanded paths
     * @param <STATE>       the type of the object that holds the state
     * @return              A new {@link PathExpander}.
     */
    public static <STATE> PathExpander<STATE> printingWrapper(
            final PathExpander<STATE> source,
            final BiFunction<Path, BranchState, Boolean> pred,
            final Paths.PathDescriptor descriptor,
            final PrintStream out )
    {
        return new PathExpander<>()
        {
            @Override
            public Iterable<Relationship> expand( Path path, BranchState state )
            {
                if ( pred.apply( path, state ) )
                {
                    out.println( Paths.pathToString( path, descriptor ) );
                }
                return source.expand( path, state );
            }

            @Override
            public PathExpander<STATE> reverse()
            {
                return printingWrapper( source.reverse(), pred, descriptor, out );
            }
        };
    }

    /**
     * A wrapper that uses {@link org.neo4j.graphdb.traversal.Paths.DefaultPathDescriptor} to print expanded paths
     * that fulfill {@link BiFunction} predicate using given {@link org.neo4j.graphdb.traversal.Paths.PathDescriptor}.
     * @param source        {@link PathExpander} to wrap.
     * @param pred          {@link BiFunction} used as predicate for printing expansion.
     * @param descriptor    {@link org.neo4j.graphdb.traversal.Paths.PathDescriptor} to use when printing paths.
     * @param out           {@link PrintStream} to use for printing expanded paths
     * @param <STATE>       the type of the object that holds the state
     * @return              A new {@link PathExpander}.
     */
    public static <STATE> PathExpander<STATE> printingWrapper(
            final PathExpander<STATE> source,
            final BiFunction<Path, BranchState, Boolean> pred,
            final Paths.PathDescriptor descriptor,
            final PrintStream out )
    {
        return new PathExpander<STATE>()
        {
            @Override
            public Iterable<Relationship> expand( Path path, BranchState state )
            {
                if ( pred.apply( path, state ) )
                {
                    out.println( Paths.pathToString( path, descriptor ) );
                }
                return source.expand( path, state );
            }

            @Override
            public PathExpander<STATE> reverse()
            {
                return printingWrapper( source.reverse(), pred, descriptor, out );
            }
        };
    }

Replace Generic With Diamond PathExpander<STATE> with PathExpander<> in method public printingWrapper(source PathExpander<STATE>, pred BiFunction<Path,BranchState,Boolean>, descriptor Paths.PathDescriptor, out PrintStream) : PathExpander<STATE> from class org.neo4j.graphdb.PathExpanders


    @Override
    public Iterable<Relationship> relationships()
    {
        return () -> new PrefetchingIterator<>()
        {
            final Iterator<Relationship> startRelationships = start.relationships().iterator();
            boolean lastReturned;

            @Override
            protected Relationship fetchNextOrNull()
            {
                if ( startRelationships.hasNext() )
                {
                    return startRelationships.next();
                }
                if ( !lastReturned )
                {
                    lastReturned = true;
                    return lastRelationship;
                }
                return null;
            }
        };
    }

    @Override
    public Iterable<Relationship> relationships()
    {
        return () -> new PrefetchingIterator<Relationship>()
        {
            final Iterator<Relationship> startRelationships = start.relationships().iterator();
            boolean lastReturned;

            @Override
            protected Relationship fetchNextOrNull()
            {
                if ( startRelationships.hasNext() )
                {
                    return startRelationships.next();
                }
                if ( !lastReturned )
                {
                    lastReturned = true;
                    return lastRelationship;
                }
                return null;
            }
        };
    }

Replace Generic With Diamond PrefetchingIterator<Relationship> with PrefetchingIterator<> in method public relationships() : Iterable<Relationship> from class org.neo4j.graphdb.impl.ExtendedPath


    @Override
    public Iterable<Relationship> reverseRelationships()
    {
        return () -> new PrefetchingIterator<>()
        {
            final Iterator<Relationship> startRelationships = start.reverseRelationships().iterator();
            boolean endReturned;

            @Override
            protected Relationship fetchNextOrNull()
            {
                if ( !endReturned )
                {
                    endReturned = true;
                    return lastRelationship;
                }
                return startRelationships.hasNext() ? startRelationships.next() : null;
            }
        };
    }

    @Override
    public Iterable<Relationship> reverseRelationships()
    {
        return () -> new PrefetchingIterator<Relationship>()
        {
            final Iterator<Relationship> startRelationships = start.reverseRelationships().iterator();
            boolean endReturned;

            @Override
            protected Relationship fetchNextOrNull()
            {
                if ( !endReturned )
                {
                    endReturned = true;
                    return lastRelationship;
                }
                return startRelationships.hasNext() ? startRelationships.next() : null;
            }
        };
    }

Replace Generic With Diamond PrefetchingIterator<Relationship> with PrefetchingIterator<> in method public reverseRelationships() : Iterable<Relationship> from class org.neo4j.graphdb.impl.ExtendedPath


    @Override
    public Iterable<Node> nodes()
    {
        return () -> new PrefetchingIterator<>()
        {
            final Iterator<Node> startNodes = start.nodes().iterator();
            boolean lastReturned;

            @Override
            protected Node fetchNextOrNull()
            {
                if ( startNodes.hasNext() )
                {
                    return startNodes.next();
                }
                if ( !lastReturned )
                {
                    lastReturned = true;
                    return endNode;
                }
                return null;
            }
        };
    }

    @Override
    public Iterable<Node> nodes()
    {
        return () -> new PrefetchingIterator<Node>()
        {
            final Iterator<Node> startNodes = start.nodes().iterator();
            boolean lastReturned;

            @Override
            protected Node fetchNextOrNull()
            {
                if ( startNodes.hasNext() )
                {
                    return startNodes.next();
                }
                if ( !lastReturned )
                {
                    lastReturned = true;
                    return endNode;
                }
                return null;
            }
        };
    }

Replace Generic With Diamond PrefetchingIterator<Node> with PrefetchingIterator<> in method public nodes() : Iterable<Node> from class org.neo4j.graphdb.impl.ExtendedPath


    @Override
    public Iterable<Node> reverseNodes()
    {
        return () -> new PrefetchingIterator<>()
        {
            final Iterator<Node> startNodes = start.reverseNodes().iterator();
            boolean endReturned;

            @Override
            protected Node fetchNextOrNull()
            {
                if ( !endReturned )
                {
                    endReturned = true;
                    return endNode;
                }
                return startNodes.hasNext() ? startNodes.next() : null;
            }
        };
    }

    @Override
    public Iterable<Node> reverseNodes()
    {
        return () -> new PrefetchingIterator<Node>()
        {
            final Iterator<Node> startNodes = start.reverseNodes().iterator();
            boolean endReturned;

            @Override
            protected Node fetchNextOrNull()
            {
                if ( !endReturned )
                {
                    endReturned = true;
                    return endNode;
                }
                return startNodes.hasNext() ? startNodes.next() : null;
            }
        };
    }

Replace Generic With Diamond PrefetchingIterator<Node> with PrefetchingIterator<> in method public reverseNodes() : Iterable<Node> from class org.neo4j.graphdb.impl.ExtendedPath


    @Override
    public Iterator<PropertyContainer> iterator()
    {
        return new PrefetchingIterator<>()
        {
            final Iterator<PropertyContainer> startEntities = start.iterator();
            int lastReturned = 2;

            @Override
            protected PropertyContainer fetchNextOrNull()
            {
                if ( startEntities.hasNext() )
                {
                    return startEntities.next();
                }
                switch ( lastReturned-- )
                {
                case 2:
                    return endNode;
                case 1:
                    return lastRelationship;
                default:
                    return null;
                }
            }
        };
    }

    @Override
    public Iterator<PropertyContainer> iterator()
    {
        return new PrefetchingIterator<PropertyContainer>()
        {
            final Iterator<PropertyContainer> startEntities = start.iterator();
            int lastReturned = 2;

            @Override
            protected PropertyContainer fetchNextOrNull()
            {
                if ( startEntities.hasNext() )
                {
                    return startEntities.next();
                }
                switch ( lastReturned-- )
                {
                case 2: return endNode;
                case 1: return lastRelationship;
                default: return null;
                }
            }
        };
    }

Replace Generic With Diamond PrefetchingIterator<PropertyContainer> with PrefetchingIterator<> in method public iterator() : Iterator<PropertyContainer> from class org.neo4j.graphdb.impl.ExtendedPath


    /**
     * Returns an {@link Evaluator} which includes positions down to {@code depth}
     * and prunes everything deeper than that.
     *
     * @param depth   the max depth to traverse to.
     * @param <STATE> the type of the state object.
     * @return Returns an {@link Evaluator} which includes positions down to
     *         {@code depth} and prunes everything deeper than that.
     */
    public static <STATE> PathEvaluator<STATE> toDepth( final int depth )
    {
        return new PathEvaluator.Adapter<>()
        {
            @Override
            public Evaluation evaluate( Path path, BranchState state )
            {
                int pathLength = path.length();
                return Evaluation.of( pathLength <= depth, pathLength < depth );
            }
        };
    }

    /**
     * Returns an {@link Evaluator} which includes positions down to {@code depth}
     * and prunes everything deeper than that.
     *
     * @param depth   the max depth to traverse to.
     * @param <STATE> the type of the state object.
     * @return Returns an {@link Evaluator} which includes positions down to
     *         {@code depth} and prunes everything deeper than that.
     */
    public static <STATE> PathEvaluator<STATE> toDepth( final int depth )
    {
        return new PathEvaluator.Adapter<STATE>()
        {
            @Override
            public Evaluation evaluate( Path path, BranchState state )
            {
                int pathLength = path.length();
                return Evaluation.of( pathLength <= depth, pathLength < depth );
            }
        };
    }

Replace Generic With Diamond PathEvaluator.Adapter<STATE> with PathEvaluator.Adapter<> in method public toDepth(depth int) : PathEvaluator<STATE> from class org.neo4j.graphdb.traversal.Evaluators


    /**
     * Returns an {@link Evaluator} which only includes positions from {@code depth}
     * and deeper and never prunes anything.
     *
     * @param depth   the depth to start include positions from.
     * @param <STATE> the type of the state object.
     * @return Returns an {@link Evaluator} which only includes positions from
     *         {@code depth} and deeper and never prunes anything.
     */
    public static <STATE> PathEvaluator<STATE> fromDepth( final int depth )
    {
        return new PathEvaluator.Adapter<>()
        {
            @Override
            public Evaluation evaluate( Path path, BranchState state )
            {
                return Evaluation.ofIncludes( path.length() >= depth );
            }
        };
    }

    /**
     * Returns an {@link Evaluator} which only includes positions from {@code depth}
     * and deeper and never prunes anything.
     *
     * @param depth   the depth to start include positions from.
     * @param <STATE> the type of the state object.
     * @return Returns an {@link Evaluator} which only includes positions from
     *         {@code depth} and deeper and never prunes anything.
     */
    public static <STATE> PathEvaluator<STATE> fromDepth( final int depth )
    {
        return new PathEvaluator.Adapter<STATE>()
        {
            @Override
            public Evaluation evaluate( Path path, BranchState state )
            {
                return Evaluation.ofIncludes( path.length() >= depth );
            }
        };
    }

Replace Generic With Diamond PathEvaluator.Adapter<STATE> with PathEvaluator.Adapter<> in method public fromDepth(depth int) : PathEvaluator<STATE> from class org.neo4j.graphdb.traversal.Evaluators


    /**
     * Returns an {@link Evaluator} which only includes positions at {@code depth}
     * and prunes everything deeper than that.
     *
     * @param depth   the depth to start include positions from.
     * @param <STATE> the type of the state object.
     * @return Returns an {@link Evaluator} which only includes positions at
     *         {@code depth} and prunes everything deeper than that.
     */
    public static <STATE> PathEvaluator<STATE> atDepth( final int depth )
    {
        return new PathEvaluator.Adapter<>()
        {
            @Override
            public Evaluation evaluate( Path path, BranchState state )
            {
                return path.length() == depth ? Evaluation.INCLUDE_AND_PRUNE : Evaluation.EXCLUDE_AND_CONTINUE;
            }
        };
    }

    /**
     * Returns an {@link Evaluator} which only includes positions at {@code depth}
     * and prunes everything deeper than that.
     *
     * @param depth   the depth to start include positions from.
     * @param <STATE> the type of the state object.
     * @return Returns an {@link Evaluator} which only includes positions at
     *         {@code depth} and prunes everything deeper than that.
     */
    public static <STATE> PathEvaluator<STATE> atDepth( final int depth )
    {
        return new PathEvaluator.Adapter<STATE>()
        {
            @Override
            public Evaluation evaluate( Path path, BranchState state )
            {
                return path.length() == depth ? Evaluation.INCLUDE_AND_PRUNE : Evaluation.EXCLUDE_AND_CONTINUE;
            }
        };
    }

Replace Generic With Diamond PathEvaluator.Adapter<STATE> with PathEvaluator.Adapter<> in method public atDepth(depth int) : PathEvaluator<STATE> from class org.neo4j.graphdb.traversal.Evaluators


    /**
     * Returns an {@link Evaluator} which only includes positions between
     * depths {@code minDepth} and {@code maxDepth}. It prunes everything deeper
     * than {@code maxDepth}.
     *
     * @param minDepth minimum depth a position must have to be included.
     * @param maxDepth maximum depth a position must have to be included.
     * @param <STATE>  the type of the state object.
     * @return Returns an {@link Evaluator} which only includes positions between
     *         depths {@code minDepth} and {@code maxDepth}. It prunes everything deeper
     *         than {@code maxDepth}.
     */
    public static <STATE> PathEvaluator<STATE> includingDepths( final int minDepth, final int maxDepth )
    {
        return new PathEvaluator.Adapter<>()
        {
            @Override
            public Evaluation evaluate( Path path, BranchState state )
            {
                int length = path.length();
                return Evaluation.of( length >= minDepth && length <= maxDepth, length < maxDepth );
            }
        };
    }

    /**
     * Returns an {@link Evaluator} which only includes positions between
     * depths {@code minDepth} and {@code maxDepth}. It prunes everything deeper
     * than {@code maxDepth}.
     *
     * @param minDepth minimum depth a position must have to be included.
     * @param maxDepth maximum depth a position must have to be included.
     * @param <STATE>  the type of the state object.
     * @return Returns an {@link Evaluator} which only includes positions between
     *         depths {@code minDepth} and {@code maxDepth}. It prunes everything deeper
     *         than {@code maxDepth}.
     */
    public static <STATE> PathEvaluator<STATE> includingDepths( final int minDepth, final int maxDepth )
    {
        return new PathEvaluator.Adapter<STATE>()
        {
            @Override
            public Evaluation evaluate( Path path, BranchState state )
            {
                int length = path.length();
                return Evaluation.of( length >= minDepth && length <= maxDepth, length < maxDepth );
            }
        };
    }

Replace Generic With Diamond PathEvaluator.Adapter<STATE> with PathEvaluator.Adapter<> in method public includingDepths(minDepth int, maxDepth int) : PathEvaluator<STATE> from class org.neo4j.graphdb.traversal.Evaluators


    /**
     * 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.
     * @param <STATE>             the type of the state object.
     * @return an {@link Evaluator} which compares the type of the last relationship
     *         in a {@link Path} to a given set of relationship types.
     */
    public static <STATE> PathEvaluator<STATE> 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.
     * @param <STATE>             the type of the state object.
     * @return an {@link Evaluator} which compares the type of the last relationship
     *         in a {@link Path} to a given set of relationship types.
     */
    public static <STATE> PathEvaluator<STATE> lastRelationshipTypeIs( final Evaluation evaluationIfMatch,
            final Evaluation evaluationIfNoMatch, final RelationshipType type, RelationshipType... orAnyOfTheseTypes )
    {
        if ( orAnyOfTheseTypes.length == 0 )
        {
            return new PathEvaluator.Adapter<STATE>()
            {
                @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<STATE>()
        {
            @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 PathEvaluator.Adapter<STATE> with PathEvaluator.Adapter<> in method public lastRelationshipTypeIs(evaluationIfMatch Evaluation, evaluationIfNoMatch Evaluation, type RelationshipType, orAnyOfTheseTypes RelationshipType...) : PathEvaluator<STATE> 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.
     * @param <STATE>             the type of the state object.
     * @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}.
     */
    public static <STATE> PathEvaluator<STATE> 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.
     * @param <STATE>             the type of the state object.
     * @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}.
     */
    public static <STATE> PathEvaluator<STATE> endNodeIs( final Evaluation evaluationIfMatch, final Evaluation
        evaluationIfNoMatch,
            Node... possibleEndNodes )
    {
        if ( possibleEndNodes.length == 1 )
        {
            final Node target = possibleEndNodes[0];
            return new PathEvaluator.Adapter<STATE>()
            {
                @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<STATE>()
        {
            @Override
            public Evaluation evaluate( Path path, BranchState state )
            {
                return endNodes.contains( path.endNode() ) ? evaluationIfMatch : evaluationIfNoMatch;
            }
        };
    }

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


    /**
     * Evaluator which decides to include a {@link Path} if all the
     * {@code nodes} exist in it.
     *
     * @param nodes   {@link Node}s that must exist in a {@link Path} for it
     *                to be included.
     * @param <STATE> the type of the state object.
     * @return {@link Evaluation#INCLUDE_AND_CONTINUE} if all {@code nodes}
     *         exist in a given {@link Path}, otherwise
     *         {@link Evaluation#EXCLUDE_AND_CONTINUE}.
     */
    public static <STATE> PathEvaluator<STATE> includeIfContainsAll( final Node... nodes )
    {
        if ( nodes.length == 1 )
        {
            return new PathEvaluator.Adapter<>()
            {
                @Override
                public Evaluation evaluate( Path path, BranchState state )
                {
                    for ( Node node : path.reverseNodes() )
                    {
                        if ( node.equals( nodes[0] ) )
                        {
                            return Evaluation.INCLUDE_AND_CONTINUE;
                        }
                    }
                    return Evaluation.EXCLUDE_AND_CONTINUE;
                }
            };
        }

        final Set<Node> fullSet = new HashSet<>( asList( nodes ) );
        return new PathEvaluator.Adapter<>()
        {
            @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;
            }
        };
    }

    /**
     * Evaluator which decides to include a {@link Path} if all the
     * {@code nodes} exist in it.
     *
     * @param nodes   {@link Node}s that must exist in a {@link Path} for it
     *                to be included.
     * @param <STATE> the type of the state object.
     * @return {@link Evaluation#INCLUDE_AND_CONTINUE} if all {@code nodes}
     *         exist in a given {@link Path}, otherwise
     *         {@link Evaluation#EXCLUDE_AND_CONTINUE}.
     */
    public static <STATE> PathEvaluator<STATE> includeIfContainsAll( final Node... nodes )
    {
        if ( nodes.length == 1 )
        {
            return new PathEvaluator.Adapter<STATE>()
            {
                @Override
                public Evaluation evaluate( Path path, BranchState state )
                {
                    for ( Node node : path.reverseNodes() )
                    {
                        if ( node.equals( nodes[0] ) )
                        {
                            return Evaluation.INCLUDE_AND_CONTINUE;
                        }
                    }
                    return Evaluation.EXCLUDE_AND_CONTINUE;
                }
            };
        }

        final Set<Node> fullSet = new HashSet<>( asList( nodes ) );
        return new PathEvaluator.Adapter<STATE>()
        {
            @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;
            }
        };
    }

Replace Generic With Diamond PathEvaluator.Adapter<STATE> with PathEvaluator.Adapter<> in method public includeIfContainsAll(nodes Node...) : PathEvaluator<STATE> from class org.neo4j.graphdb.traversal.Evaluators


    /**
     * Whereas adding {@link Evaluator}s to a {@link TraversalDescription} puts those
     * evaluators in {@code AND-mode} this can group many evaluators in {@code OR-mode}.
     *
     * @param evaluators represented as one evaluators. If any of the evaluators decides
     *                   to include a path it will be included.
     * @param <STATE>    the type of the state object.
     * @return an {@link Evaluator} which decides to include a path if any of the supplied
     *         evaluators wants to include it.
     */
    public static <STATE> PathEvaluator<STATE> includeIfAcceptedByAny( final PathEvaluator... evaluators )
    {
        return new PathEvaluator.Adapter<>()
        {
            @SuppressWarnings( "unchecked" )
            @Override
            public Evaluation evaluate( Path path, BranchState state )
            {
                for ( PathEvaluator evaluator : evaluators )
                {
                    if ( evaluator.evaluate( path, state ).includes() )
                    {
                        return Evaluation.INCLUDE_AND_CONTINUE;
                    }
                }
                return Evaluation.EXCLUDE_AND_CONTINUE;
            }
        };
    }

    /**
     * Whereas adding {@link Evaluator}s to a {@link TraversalDescription} puts those
     * evaluators in {@code AND-mode} this can group many evaluators in {@code OR-mode}.
     *
     * @param evaluators represented as one evaluators. If any of the evaluators decides
     *                   to include a path it will be included.
     * @param <STATE>    the type of the state object.
     * @return an {@link Evaluator} which decides to include a path if any of the supplied
     *         evaluators wants to include it.
     */
    public static <STATE> PathEvaluator<STATE> includeIfAcceptedByAny( final PathEvaluator... evaluators )
    {
        return new PathEvaluator.Adapter<STATE>()
        {
            @SuppressWarnings( "unchecked" )
            @Override
            public Evaluation evaluate( Path path, BranchState state )
            {
                for ( PathEvaluator evaluator : evaluators )
                {
                    if ( evaluator.evaluate( path, state ).includes() )
                    {
                        return Evaluation.INCLUDE_AND_CONTINUE;
                    }
                }
                return Evaluation.EXCLUDE_AND_CONTINUE;
            }
        };
    }

Replace Generic With Diamond PathEvaluator.Adapter<STATE> with PathEvaluator.Adapter<> in method public includeIfAcceptedByAny(evaluators PathEvaluator...) : PathEvaluator<STATE> from class org.neo4j.graphdb.traversal.Evaluators


    /**
     * Whereas adding {@link Evaluator}s to a {@link TraversalDescription} puts those
     * evaluators in {@code AND-mode} this can group many evaluators in {@code OR-mode}.
     *
     * @param evaluators represented as one evaluators. If any of the evaluators decides
     *                   to include a path it will be included.
     * @param <STATE>    the type of the state object.
     * @return an {@link Evaluator} which decides to include a path if any of the supplied
     *         evaluators wants to include it.
     */
    public static <STATE> PathEvaluator<STATE> includeIfAcceptedByAny( final Evaluator... evaluators )
    {
        return new PathEvaluator.Adapter<>()
        {
            @Override
            public Evaluation evaluate( Path path, BranchState state )
            {
                for ( Evaluator evaluator : evaluators )
                {
                    if ( evaluator.evaluate( path ).includes() )
                    {
                        return Evaluation.INCLUDE_AND_CONTINUE;
                    }
                }
                return Evaluation.EXCLUDE_AND_CONTINUE;
            }
        };
    }

    /**
     * Whereas adding {@link Evaluator}s to a {@link TraversalDescription} puts those
     * evaluators in {@code AND-mode} this can group many evaluators in {@code OR-mode}.
     *
     * @param evaluators represented as one evaluators. If any of the evaluators decides
     *                   to include a path it will be included.
     * @param <STATE>    the type of the state object.
     * @return an {@link Evaluator} which decides to include a path if any of the supplied
     *         evaluators wants to include it.
     */
    public static <STATE> PathEvaluator<STATE> includeIfAcceptedByAny( final Evaluator... evaluators )
    {
        return new PathEvaluator.Adapter<STATE>()
        {
            @Override
            public Evaluation evaluate( Path path, BranchState state )
            {
                for ( Evaluator evaluator : evaluators )
                {
                    if ( evaluator.evaluate( path ).includes() )
                    {
                        return Evaluation.INCLUDE_AND_CONTINUE;
                    }
                }
                return Evaluation.EXCLUDE_AND_CONTINUE;
            }
        };
    }

Replace Generic With Diamond PathEvaluator.Adapter<STATE> with PathEvaluator.Adapter<> in method public includeIfAcceptedByAny(evaluators Evaluator...) : PathEvaluator<STATE> from class org.neo4j.graphdb.traversal.Evaluators


    /**
     * Returns {@link Evaluator}s for paths with the specified depth and with an end node from the list of
     * possibleEndNodes.
     * @param depth The exact depth to filter the returned path evaluators.
     * @param possibleEndNodes Filter for the possible nodes to end the path on.
     * @param <STATE> the type of the state object.
     * @return {@link Evaluator}s for paths with the specified depth and with an end node from the list of
     * possibleEndNodes.
     */
    public static <STATE> PathEvaluator<STATE> endNodeIsAtDepth( final int depth, Node... possibleEndNodes )
    {
        if ( possibleEndNodes.length == 1 )
        {
            final Node target = possibleEndNodes[0];
            return new PathEvaluator.Adapter<>()
            {
                @Override
                public Evaluation evaluate( Path path, BranchState state )
                {
                    if ( path.length() == depth )
                    {
                        return target.equals( path.endNode() ) ? Evaluation.INCLUDE_AND_PRUNE : Evaluation.EXCLUDE_AND_PRUNE;
                    }
                    return Evaluation.EXCLUDE_AND_CONTINUE;
                }
            };
        }

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

    /**
     * Returns {@link Evaluator}s for paths with the specified depth and with an end node from the list of
     * possibleEndNodes.
     * @param depth The exact depth to filter the returned path evaluators.
     * @param possibleEndNodes Filter for the possible nodes to end the path on.
     * @param <STATE> the type of the state object.
     * @return {@link Evaluator}s for paths with the specified depth and with an end node from the list of
     * possibleEndNodes.
     */
    public static <STATE> PathEvaluator<STATE> endNodeIsAtDepth( final int depth, Node... possibleEndNodes )
    {
        if ( possibleEndNodes.length == 1 )
        {
            final Node target = possibleEndNodes[0];
            return new PathEvaluator.Adapter<STATE>()
            {
                @Override
                public Evaluation evaluate( Path path, BranchState state )
                {
                    if ( path.length() == depth )
                    {
                        return target.equals( path.endNode() ) ? Evaluation.INCLUDE_AND_PRUNE : Evaluation.EXCLUDE_AND_PRUNE;
                    }
                    return Evaluation.EXCLUDE_AND_CONTINUE;
                }
            };
        }

        final Set<Node> endNodes = new HashSet<>( asList( possibleEndNodes ) );
        return new PathEvaluator.Adapter<STATE>()
        {
            @Override
            public Evaluation evaluate( Path path, BranchState state )
            {
                if ( path.length() == depth )
                {
                    return endNodes.contains( path.endNode() ) ? Evaluation.INCLUDE_AND_PRUNE : Evaluation.EXCLUDE_AND_PRUNE;
                }
                return Evaluation.EXCLUDE_AND_CONTINUE;
            }
        };
    }

Replace Generic With Diamond PathEvaluator.Adapter<STATE> with PathEvaluator.Adapter<> in method public endNodeIsAtDepth(depth int, possibleEndNodes Node...) : PathEvaluator<STATE> from class org.neo4j.graphdb.traversal.Evaluators


    /**
     * Returns a quite simple string representation of a {@link Path}. It
     * doesn't print relationship types or ids, just directions.
     * @param path the {@link Path} to build a string representation of.
     * @return a quite simple representation of a {@link Path}.
     */
    public static String simplePathToString( Path path )
    {
        return pathToString( path, new DefaultPathDescriptor<>()
        {
            @Override
            public String relationshipRepresentation( Path path, Node from,
                                                      Relationship relationship )
            {
                return relationship.getStartNode().equals( from ) ? "-->" : "<--";
            }
        } );
    }

    /**
     * Returns a quite simple string representation of a {@link Path}. It
     * doesn't print relationship types or ids, just directions.
     * @param path the {@link Path} to build a string representation of.
     * @return a quite simple representation of a {@link Path}.
     */
    public static String simplePathToString( Path path )
    {
        return pathToString( path, new DefaultPathDescriptor<Path>()
        {
            @Override
            public String relationshipRepresentation( Path path, Node from,
                                                      Relationship relationship )
            {
                return relationship.getStartNode().equals( from ) ? "-->" : "<--";
            }
        } );
    }

Replace Generic With Diamond DefaultPathDescriptor<Path> with DefaultPathDescriptor<> in method public simplePathToString(path Path) : String from class org.neo4j.graphdb.traversal.Paths


    /**
     * Returns a quite simple string representation of a {@link Path}. It
     * doesn't print relationship types or ids, just directions. it uses the
     * {@code nodePropertyKey} to try to display that property value as in the
     * node representation instead of the node id. If that property doesn't
     * exist, the id is used.
     * @param path the {@link Path} to build a string representation of.
     * @param nodePropertyKey the key of the property value to display
     * @return a quite simple representation of a {@link Path}.
     */
    public static String simplePathToString( Path path, final String nodePropertyKey )
    {
        return pathToString( path, new DefaultPathDescriptor<>()
        {
            @Override
            public String nodeRepresentation( Path path, Node node )
            {
                return "(" + node.getProperty( nodePropertyKey, node.getId() ) + ")";
            }

            @Override
            public String relationshipRepresentation( Path path, Node from,
                                                      Relationship relationship )
            {
                return relationship.getStartNode().equals( from ) ? "-->" : "<--";
            }
        } );
    }

    /**
     * Returns a quite simple string representation of a {@link Path}. It
     * doesn't print relationship types or ids, just directions. it uses the
     * {@code nodePropertyKey} to try to display that property value as in the
     * node representation instead of the node id. If that property doesn't
     * exist, the id is used.
     * @param path the {@link Path} to build a string representation of.
     * @param nodePropertyKey the key of the property value to display
     * @return a quite simple representation of a {@link Path}.
     */
    public static String simplePathToString( Path path, final String nodePropertyKey )
    {
        return pathToString( path, new DefaultPathDescriptor<Path>()
        {
            @Override
            public String nodeRepresentation( Path path, Node node )
            {
                return "(" + node.getProperty( nodePropertyKey, node.getId() ) + ")";
            }

            @Override
            public String relationshipRepresentation( Path path, Node from,
                                                      Relationship relationship )
            {
                return relationship.getStartNode().equals( from ) ? "-->" : "<--";
            }
        } );
    }

Replace Generic With Diamond DefaultPathDescriptor<Path> with DefaultPathDescriptor<> in method public simplePathToString(path Path, nodePropertyKey String) : String from class org.neo4j.graphdb.traversal.Paths


    /**
     * Create a new {@link Paths.PathDescriptor} that prints values of listed property keys
     * and id of nodes and relationships if configured so.
     * @param nodeId            true if node id should be included.
     * @param relId             true if relationship id should be included.
     * @param propertyKeys      all property keys that should be included.
     * @param <T>               the type of the {@link Path}
     * @return                  a new {@link Paths.PathDescriptor}
     */
    public static <T extends Path> PathDescriptor<T> descriptorForIdAndProperties( final boolean nodeId,
    final boolean relId, final String... propertyKeys )
    {
        return new Paths.PathDescriptor<>()
        {
            @Override
            public String nodeRepresentation( T path, Node node )
            {
                String representation = representation( node );
                return "(" + (nodeId ? node.getId() : "") +
                       (nodeId && !representation.equals( "" ) ? "," : "") +
                       representation + ")";
            }

            private String representation( PropertyContainer entity )
            {
                StringBuilder builder = new StringBuilder();
                for ( String key : propertyKeys )
                {
                    Object value = entity.getProperty( key, null );
                    if ( value != null )
                    {
                        if ( builder.length() > 0 )
                        {
                            builder.append( "," );
                        }
                        builder.append( value );
                    }
                }
                return builder.toString();
            }

            @Override
            public String relationshipRepresentation( T path, Node from, Relationship relationship )
            {
                Direction direction = relationship.getEndNode().equals( from ) ? Direction.INCOMING : Direction.OUTGOING;
                StringBuilder builder = new StringBuilder();
                if ( direction.equals( Direction.INCOMING ) )
                {
                    builder.append( "<" );
                }
                builder.append( "-[" + (relId ? relationship.getId() : "") );
                String representation = representation( relationship );
                if ( relId && !representation.equals( "" ) )
                {
                    builder.append( "," );
                }
                builder.append( representation );
                builder.append( "]-" );

                if ( direction.equals( Direction.OUTGOING ) )
                {
                    builder.append( ">" );
                }
                return builder.toString();
            }
        };
    }

    /**
     * Create a new {@link Paths.PathDescriptor} that prints values of listed property keys
     * and id of nodes and relationships if configured so.
     * @param nodeId            true if node id should be included.
     * @param relId             true if relationship id should be included.
     * @param propertyKeys      all property keys that should be included.
     * @param <T>               the type of the {@link Path}
     * @return                  a new {@link Paths.PathDescriptor}
     */
    public static <T extends Path> PathDescriptor<T> descriptorForIdAndProperties( final boolean nodeId,
    final boolean relId, final String... propertyKeys )
    {
        return new Paths.PathDescriptor<T>()
        {
            @Override
            public String nodeRepresentation( T path, Node node )
            {
                String representation = representation( node );
                return "(" + (nodeId ? node.getId() : "" ) +
                       ( nodeId && !representation.equals( "" ) ? "," : "" ) +
                       representation + ")";
            }

            private String representation( PropertyContainer entity )
            {
                StringBuilder builder = new StringBuilder();
                for ( String key : propertyKeys )
                {
                    Object value = entity.getProperty( key, null );
                    if ( value != null )
                    {
                        if ( builder.length() > 0 )
                        {
                            builder.append( "," );
                        }
                        builder.append( value );
                    }
                }
                return builder.toString();
            }

            @Override
            public String relationshipRepresentation( T path, Node from, Relationship relationship )
            {
                Direction direction = relationship.getEndNode().equals( from ) ? Direction.INCOMING : Direction.OUTGOING;
                StringBuilder builder = new StringBuilder();
                if ( direction.equals( Direction.INCOMING ) )
                {
                    builder.append( "<" );
                }
                builder.append( "-[" + (relId ? relationship.getId() : "") );
                String representation = representation( relationship );
                if ( relId && !representation.equals( "" ) )
                {
                    builder.append( "," );
                }
                builder.append( representation );
                builder.append( "]-" );

                if ( direction.equals( Direction.OUTGOING ) )
                {
                    builder.append( ">" );
                }
                return builder.toString();
            }
        };
    }

Replace Generic With Diamond Paths.PathDescriptor<T> with Paths.PathDescriptor<> in method public descriptorForIdAndProperties(nodeId boolean, relId boolean, propertyKeys String...) : PathDescriptor<T> from class org.neo4j.graphdb.traversal.Paths


    @Override
    public MemoryStatsVisitor.Visitable memoryEstimation( long numberOfNodes )
    {
        return visitor ->
        {
            int trackerSize = numberOfNodes > IntTracker.MAX_ID ? BigIdTracker.SIZE : IntTracker.SIZE;
            visitor.offHeapUsage( numberOfNodes * (Long.BYTES /*data*/ + trackerSize /*tracker*/) );
        };
    }

    @Override
    public MemoryStatsVisitor.Visitable memoryEstimation( long numberOfNodes )
    {
        return new MemoryStatsVisitor.Visitable()
        {
            @Override
            public void acceptMemoryStatsVisitor( MemoryStatsVisitor visitor )
            {
                int trackerSize = numberOfNodes > IntTracker.MAX_ID ? BigIdTracker.SIZE : IntTracker.SIZE;
                visitor.offHeapUsage( numberOfNodes * (Long.BYTES /*data*/ + trackerSize /*tracker*/) );
            }
        };
    }

Replace Anonymous With Lambda org.neo4j.internal.batchimport.cache.idmapping.string.EncodingIdMapper.memoryEstimation.new MemoryStatsVisitor.Visitable with visitor -> {int trackerSize=numberOfNodes > IntTracker.MAX_ID ? BigIdTracker.SIZE : IntTracker.SIZE; in method public memoryEstimation(numberOfNodes long) : MemoryStatsVisitor.Visitable from class org.neo4j.internal.batchimport.cache.idmapping.string.EncodingIdMapper


    public static FileVisitor<Path> onlyMatching( Predicate<Path> predicate, FileVisitor<Path> wrapped )
    {
        return new FileVisitor<>()
        {
            @Override
            public FileVisitResult preVisitDirectory( Path dir, BasicFileAttributes attrs ) throws IOException
            {
                return predicate.test( dir ) ? wrapped.preVisitDirectory( dir, attrs ) : FileVisitResult.SKIP_SUBTREE;
            }

            @Override
            public FileVisitResult visitFile( Path file, BasicFileAttributes attrs ) throws IOException
            {
                return predicate.test( file ) ? wrapped.visitFile( file, attrs ) : FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult visitFileFailed( Path file, IOException e ) throws IOException
            {
                return predicate.test( file ) ? wrapped.visitFileFailed( file, e ) : FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult postVisitDirectory( Path dir, IOException e ) throws IOException
            {
                return predicate.test( dir ) ? wrapped.postVisitDirectory( dir, e ) : FileVisitResult.CONTINUE;
            }
        };
    }

    public static FileVisitor<Path> onlyMatching( Predicate<Path> predicate, FileVisitor<Path> wrapped )
    {
        return new FileVisitor<Path>()
        {
            @Override
            public FileVisitResult preVisitDirectory( Path dir, BasicFileAttributes attrs ) throws IOException
            {
                return predicate.test( dir ) ? wrapped.preVisitDirectory( dir, attrs ) : FileVisitResult.SKIP_SUBTREE;
            }

            @Override
            public FileVisitResult visitFile( Path file, BasicFileAttributes attrs ) throws IOException
            {
                return predicate.test( file ) ? wrapped.visitFile( file, attrs ) : FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult visitFileFailed( Path file, IOException e ) throws IOException
            {
                return predicate.test( file ) ? wrapped.visitFileFailed( file, e ) : FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult postVisitDirectory( Path dir, IOException e ) throws IOException
            {
                return predicate.test( dir ) ? wrapped.postVisitDirectory( dir, e ) : FileVisitResult.CONTINUE;
            }
        };
    }

Replace Generic With Diamond FileVisitor<Path> with FileVisitor<> in method public onlyMatching(predicate Predicate<Path>, wrapped FileVisitor<Path>) : FileVisitor<Path> from class org.neo4j.io.fs.FileVisitors


    public static FileVisitor<Path> throwExceptions( FileVisitor<Path> wrapped )
    {
        return new Decorator<>( wrapped )
        {
            @Override
            public FileVisitResult visitFileFailed( Path file, IOException e ) throws IOException
            {
                if ( e != null )
                {
                    throw e;
                }
                return super.visitFileFailed( file, null );
            }

            @Override
            public FileVisitResult postVisitDirectory( Path dir, IOException e ) throws IOException
            {
                if ( e != null )
                {
                    throw e;
                }
                return super.postVisitDirectory( dir, null );
            }
        };
    }

    public static FileVisitor<Path> throwExceptions( FileVisitor<Path> wrapped )
    {
        return new Decorator<Path>( wrapped )
        {
            @Override
            public FileVisitResult visitFileFailed( Path file, IOException e ) throws IOException
            {
                if ( e != null )
                {
                    throw e;
                }
                return super.visitFileFailed( file, null );
            }

            @Override
            public FileVisitResult postVisitDirectory( Path dir, IOException e ) throws IOException
            {
                if ( e != null )
                {
                    throw e;
                }
                return super.postVisitDirectory( dir, null );
            }
        };
    }

Replace Generic With Diamond Decorator<Path> with Decorator<> in method public throwExceptions(wrapped FileVisitor<Path>) : FileVisitor<Path> from class org.neo4j.io.fs.FileVisitors


    public static FileVisitor<Path> onDirectory( ThrowingConsumer<Path, IOException> operation,
                                                 FileVisitor<Path> wrapped )
    {
        return new Decorator<>( wrapped )
        {
            @Override
            public FileVisitResult preVisitDirectory( Path dir, BasicFileAttributes attrs ) throws IOException
            {
                operation.accept( dir );
                return super.preVisitDirectory( dir, attrs );
            }
        };
    }

    public static FileVisitor<Path> onDirectory( ThrowingConsumer<Path, IOException> operation,
                                                 FileVisitor<Path> wrapped )
    {
        return new Decorator<Path>( wrapped )
        {
            @Override
            public FileVisitResult preVisitDirectory( Path dir, BasicFileAttributes attrs ) throws IOException
            {
                operation.accept( dir );
                return super.preVisitDirectory( dir, attrs );
            }
        };
    }

Replace Generic With Diamond Decorator<Path> with Decorator<> in method public onDirectory(operation ThrowingConsumer<Path,IOException>, wrapped FileVisitor<Path>) : FileVisitor<Path> from class org.neo4j.io.fs.FileVisitors


    public static FileVisitor<Path> onFile( ThrowingConsumer<Path, IOException> operation, FileVisitor<Path> wrapped )
    {
        return new Decorator<>( wrapped )
        {
            @Override
            public FileVisitResult visitFile( Path file, BasicFileAttributes attrs ) throws IOException
            {
                operation.accept( file );
                return super.visitFile( file, attrs );
            }
        };
    }

    public static FileVisitor<Path> onFile( ThrowingConsumer<Path, IOException> operation, FileVisitor<Path> wrapped )
    {
        return new Decorator<Path>( wrapped )
        {
            @Override
            public FileVisitResult visitFile( Path file, BasicFileAttributes attrs ) throws IOException
            {
                operation.accept( file );
                return super.visitFile( file, attrs );
            }
        };
    }

Replace Generic With Diamond Decorator<Path> with Decorator<> in method public onFile(operation ThrowingConsumer<Path,IOException>, wrapped FileVisitor<Path>) : FileVisitor<Path> from class org.neo4j.io.fs.FileVisitors


    public static FileVisitor<Path> justContinue()
    {
        return new FileVisitor<>()
        {
            @Override
            public FileVisitResult preVisitDirectory( Path dir, BasicFileAttributes attrs )
            {
                return FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult visitFile( Path file, BasicFileAttributes attrs )
            {
                return FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult visitFileFailed( Path file, IOException e )
            {
                return FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult postVisitDirectory( Path dir, IOException e )
            {
                return FileVisitResult.CONTINUE;
            }
        };
    }

    public static FileVisitor<Path> justContinue()
    {
        return new FileVisitor<Path>()
        {
            @Override
            public FileVisitResult preVisitDirectory( Path dir, BasicFileAttributes attrs )
            {
                return FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult visitFile( Path file, BasicFileAttributes attrs )
            {
                return FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult visitFileFailed( Path file, IOException e )
            {
                return FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult postVisitDirectory( Path dir, IOException e )
            {
                return FileVisitResult.CONTINUE;
            }
        };
    }

Replace Generic With Diamond FileVisitor<Path> with FileVisitor<> in method public justContinue() : FileVisitor<Path> from class org.neo4j.io.fs.FileVisitors


        @Override
        public BoundedIterable<Long> newAllEntriesReader()
        {
            return new BoundedIterable<>()
            {
                @Override
                public long maxCount()
                {
                    return 0;
                }

                @Override
                public void close()
                {
                }

                @Override
                public Iterator<Long> iterator()
                {
                    return emptyIterator();
                }
            };
        }

        @Override
        public BoundedIterable<Long> newAllEntriesReader()
        {
            return new BoundedIterable<Long>()
            {
                @Override
                public long maxCount()
                {
                    return 0;
                }

                @Override
                public void close()
                {
                }

                @Override
                public Iterator<Long> iterator()
                {
                    return emptyIterator();
                }
            };
        }

Replace Generic With Diamond BoundedIterable<Long> with BoundedIterable<> in method public newAllEntriesReader() : BoundedIterable<Long> from class org.neo4j.kernel.api.index.IndexAccessor.Adapter


    @Override
    public Iterator<IndexUpdater> iterator()
    {
        return new PrefetchingIterator<>()
        {
            private Iterator<SchemaDescriptor> descriptors = indexMap.descriptors();

            @Override
            protected IndexUpdater fetchNextOrNull()
            {
                if ( descriptors.hasNext() )
                {
                    return getUpdater( descriptors.next() );
                }
                return null;
            }
        };
    }

    @Override
    public Iterator<IndexUpdater> iterator()
    {
        return new PrefetchingIterator<IndexUpdater>()
        {
            private Iterator<SchemaDescriptor> descriptors = indexMap.descriptors();
            @Override
            protected IndexUpdater fetchNextOrNull()
            {
                if ( descriptors.hasNext() )
                {
                    return getUpdater( descriptors.next() );
                }
                return null;
            }
        };
    }

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


    private Predicate<Long> createSamplingPredicate()
    {
        return new Predicate<>()
        {
            private final DoubleLongRegister output = newDoubleLongRegister();

            @Override
            public boolean test( Long indexId )
            {
                indexStatisticsStore.indexUpdatesAndSize( indexId, output );
                long updates = output.readFirst();
                long size = output.readSecond();
                long threshold = Math.round( config.updateRatio() * size );
                return updates > threshold;
            }
        };
    }

    private Predicate<Long> createSamplingPredicate()
    {
        return new Predicate<Long>()
        {
            private final DoubleLongRegister output = newDoubleLongRegister();

            @Override
            public boolean test( Long indexId )
            {
                indexStatisticsStore.indexUpdatesAndSize( indexId, output );
                long updates = output.readFirst();
                long size = output.readSecond();
                long threshold = Math.round( config.updateRatio() * size );
                return updates > threshold;
            }
        };
    }

Replace Generic With Diamond Predicate<Long> with Predicate<> in method private createSamplingPredicate() : Predicate<Long> from class org.neo4j.kernel.impl.api.index.sampling.IndexSamplingControllerFactory


        @Override
        public Iterator<LongObjectPair<Value>> iterator()
        {
            Iterator<LongLongPair> refsIterator = refs.keyValuesView().iterator();
            return new Iterator<>()
            {
                @Override
                public boolean hasNext()
                {
                    return refsIterator.hasNext();
                }

                @Override
                public LongObjectPair<Value> next()
                {
                    final LongLongPair key2ref = refsIterator.next();
                    final long key = key2ref.getOne();
                    final long ref = key2ref.getTwo();
                    final Value value = valuesContainer.get( ref );
                    return PrimitiveTuples.pair( key, value );
                }
            };
        }

        @Override
        public Iterator<LongObjectPair<Value>> iterator()
        {
            Iterator<LongLongPair> refsIterator = refs.keyValuesView().iterator();
            return new Iterator<LongObjectPair<Value>>()
            {
                @Override
                public boolean hasNext()
                {
                    return refsIterator.hasNext();
                }

                @Override
                public LongObjectPair<Value> next()
                {
                    final LongLongPair key2ref = refsIterator.next();
                    final long key = key2ref.getOne();
                    final long ref = key2ref.getTwo();
                    final Value value = valuesContainer.get( ref );
                    return PrimitiveTuples.pair( key, value );
                }
            };
        }

Replace Generic With Diamond Iterator<LongObjectPair<Value>> with Iterator<> in method public iterator() : Iterator<LongObjectPair<Value>> from class org.neo4j.kernel.impl.api.state.ValuesMap.KeyValuesView


    @Override
    public Iterable<Relationship> relationships()
    {
        return () -> new Iterator<>()
        {
            int i;

            @Override
            public boolean hasNext()
            {
                return i < relationships.length;
            }

            @Override
            public Relationship next()
            {
                return relationship( i++ );
            }
        };
    }

    @Override
    public Iterable<Relationship> relationships()
    {
        return () -> new Iterator<Relationship>()
        {
            int i;

            @Override
            public boolean hasNext()
            {
                return i < relationships.length;
            }

            @Override
            public Relationship next()
            {
                return relationship( i++ );
            }
        };
    }

Replace Generic With Diamond Iterator<Relationship> with Iterator<> in method public relationships() : Iterable<Relationship> from class org.neo4j.kernel.impl.core.PathProxy


    @Override
    public Iterable<Relationship> reverseRelationships()
    {
        return () -> new Iterator<>()
        {
            int i = relationships.length;

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

            @Override
            public Relationship next()
            {
                return relationship( --i );
            }
        };
    }

    @Override
    public Iterable<Relationship> reverseRelationships()
    {
        return () -> new Iterator<Relationship>()
        {
            int i = relationships.length;

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

            @Override
            public Relationship next()
            {
                return relationship( --i );
            }
        };
    }

Replace Generic With Diamond Iterator<Relationship> with Iterator<> in method public reverseRelationships() : Iterable<Relationship> from class org.neo4j.kernel.impl.core.PathProxy


    @Override
    public Iterable<Node> nodes()
    {
        return () -> new Iterator<>()
        {
            int i;

            @Override
            public boolean hasNext()
            {
                return i < nodes.length;
            }

            @Override
            public Node next()
            {
                return new NodeProxy( proxySPI, nodes[i++] );
            }
        };
    }

    @Override
    public Iterable<Node> nodes()
    {
        return () -> new Iterator<Node>()
        {
            int i;

            @Override
            public boolean hasNext()
            {
                return i < nodes.length;
            }

            @Override
            public Node next()
            {
                return new NodeProxy( proxySPI, nodes[i++] );
            }
        };
    }

Replace Generic With Diamond Iterator<Node> with Iterator<> in method public nodes() : Iterable<Node> from class org.neo4j.kernel.impl.core.PathProxy


    @Override
    public Iterable<Node> reverseNodes()
    {
        return () -> new Iterator<>()
        {
            int i = nodes.length;

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

            @Override
            public Node next()
            {
                return new NodeProxy( proxySPI, nodes[--i] );
            }
        };
    }

    @Override
    public Iterable<Node> reverseNodes()
    {
        return () -> new Iterator<Node>()
        {
            int i = nodes.length;

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

            @Override
            public Node next()
            {
                return new NodeProxy( proxySPI, nodes[--i] );
            }
        };
    }

Replace Generic With Diamond Iterator<Node> with Iterator<> in method public reverseNodes() : Iterable<Node> from class org.neo4j.kernel.impl.core.PathProxy


    @Override
    public Iterator<PropertyContainer> iterator()
    {
        return new Iterator<>()
        {
            int i;
            boolean relationship;

            @Override
            public boolean hasNext()
            {
                return i < relationships.length || !relationship;
            }

            @Override
            public PropertyContainer next()
            {
                if ( relationship )
                {
                    relationship = false;
                    return relationship( i++ );
                }
                else
                {
                    relationship = true;
                    return new NodeProxy( proxySPI, nodes[i] );
                }
            }
        };
    }

    @Override
    public Iterator<PropertyContainer> iterator()
    {
        return new Iterator<PropertyContainer>()
        {
            int i;
            boolean relationship;

            @Override
            public boolean hasNext()
            {
                return i < relationships.length || !relationship;
            }

            @Override
            public PropertyContainer next()
            {
                if ( relationship )
                {
                    relationship = false;
                    return relationship( i++ );
                }
                else
                {
                    relationship = true;
                    return new NodeProxy( proxySPI, nodes[i] );
                }
            }
        };
    }

Replace Generic With Diamond Iterator<PropertyContainer> with Iterator<> in method public iterator() : Iterator<PropertyContainer> from class org.neo4j.kernel.impl.core.PathProxy


    @Override
    public Iterator<Long> iterator()
    {
        KEY from = layout.newKey();
        from.initialize( Long.MIN_VALUE );
        from.initValuesAsLowest();
        KEY to = layout.newKey();
        to.initialize( Long.MAX_VALUE );
        to.initValuesAsHighest();
        try
        {
            closeSeeker();
            seeker = tree.seek( from, to );
            return new PrefetchingIterator<>()
            {
                @Override
                protected Long fetchNextOrNull()
                {
                    try
                    {
                        return seeker.next() ? seeker.key().getEntityId() : null;
                    }
                    catch ( IOException e )
                    {
                        throw new UncheckedIOException( e );
                    }
                }
            };
        }
        catch ( IOException e )
        {
            throw new UncheckedIOException( e );
        }
    }

    @Override
    public Iterator<Long> iterator()
    {
        KEY from = layout.newKey();
        from.initialize( Long.MIN_VALUE );
        from.initValuesAsLowest();
        KEY to = layout.newKey();
        to.initialize( Long.MAX_VALUE );
        to.initValuesAsHighest();
        try
        {
            closeSeeker();
            seeker = tree.seek( from, to );
            return new PrefetchingIterator<Long>()
            {
                @Override
                protected Long fetchNextOrNull()
                {
                    try
                    {
                        return seeker.next() ? seeker.key().getEntityId() : null;
                    }
                    catch ( IOException e )
                    {
                        throw new UncheckedIOException( e );
                    }
                }
            };
        }
        catch ( IOException e )
        {
            throw new UncheckedIOException( e );
        }
    }

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


    @Override
    public Iterable<Relationship> reverseRelationships()
    {
        return () -> new PrefetchingIterator<>()
        {
            private TraversalBranch branch = TraversalBranchImpl.this;

            @Override
            protected Relationship fetchNextOrNull()
            {
                try
                {
                    return branch != null ? branch.lastRelationship() : null;
                }
                finally
                {
                    branch = branch != null ? branch.parent() : null;
                }
            }
        };
    }

    @Override
    public Iterable<Relationship> reverseRelationships()
    {
        return () -> new PrefetchingIterator<Relationship>()
        {
            private TraversalBranch branch = TraversalBranchImpl.this;

            @Override
            protected Relationship fetchNextOrNull()
            {
                try
                {
                    return branch != null ? branch.lastRelationship() : null;
                }
                finally
                {
                    branch = branch != null ? branch.parent() : null;
                }
            }
        };
    }

Replace Generic With Diamond PrefetchingIterator<Relationship> with PrefetchingIterator<> in method public reverseRelationships() : Iterable<Relationship> from class org.neo4j.kernel.impl.traversal.TraversalBranchImpl


    @Override
    public Iterable<Node> reverseNodes()
    {
        return () -> new PrefetchingIterator<>()
        {
            private TraversalBranch branch = TraversalBranchImpl.this;

            @Override
            protected Node fetchNextOrNull()
            {
                try
                {
                    return branch.length() >= 0 ? branch.endNode() : null;
                }
                finally
                {
                    branch = branch.parent();
                }
            }
        };
    }

    @Override
    public Iterable<Node> reverseNodes()
    {
        return () -> new PrefetchingIterator<Node>()
        {
            private TraversalBranch branch = TraversalBranchImpl.this;

            @Override
            protected Node fetchNextOrNull()
            {
                try
                {
                    return branch.length() >= 0 ? branch.endNode() : null;
                }
                finally
                {
                    branch = branch.parent();
                }
            }
        };
    }

Replace Generic With Diamond PrefetchingIterator<Node> with PrefetchingIterator<> in method public reverseNodes() : Iterable<Node> from class org.neo4j.kernel.impl.traversal.TraversalBranchImpl


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

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

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

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

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

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

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

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

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

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

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

                }
                else
                {
                    return false;
                }
            }

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

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

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

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

            @Override
            public String toString()
            {
                return Paths.defaultPathToStringWithNotInTransactionFallback( this );
            }
        } );
    }

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

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

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

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

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

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

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

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

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

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

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

                }
                else
                {
                    return false;
                }
            }

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

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

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

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

            @Override
            public String toString()
            {
                return Paths.defaultPathToStringWithNotInTransactionFallback( this );
            }
        } );
    }

Replace Generic With Diamond Iterator<PropertyContainer> with Iterator<> in method public writePath(nodes NodeValue[], relationships RelationshipValue[]) : void from class org.neo4j.kernel.impl.util.BaseToObjectValueWriter


    public static <T, EX extends Exception> RawCursor<T,EX> rawCursorOf( Iterable<T> iterable )
    {
        return new RawCursor<>()
        {
            private CursorValue<T> current = new CursorValue<>();
            private Iterator<T> itr = iterable.iterator();

            @Override
            public T get()
            {
                return current.get();
            }

            @Override
            public boolean next() throws EX
            {
                if ( itr.hasNext() )
                {
                    current.set( itr.next() );
                    return true;
                }
                else
                {
                    current.invalidate();
                    return false;
                }
            }

            @Override
            public void close() throws EX
            {
                current.invalidate();
            }
        };
    }

    public static <T, EX extends Exception> RawCursor<T,EX> rawCursorOf( Iterable<T> iterable )
    {
        return new RawCursor<T,EX>()
        {
            private CursorValue<T> current = new CursorValue<>();
            private Iterator<T> itr = iterable.iterator();

            @Override
            public T get()
            {
                return current.get();
            }

            @Override
            public boolean next() throws EX
            {
                if ( itr.hasNext() )
                {
                    current.set( itr.next() );
                    return true;
                }
                else
                {
                    current.invalidate();
                    return false;
                }
            }

            @Override
            public void close() throws EX
            {
                current.invalidate();
            }
        };
    }

Replace Generic With Diamond RawCursor<T,EX> with RawCursor<> in method public rawCursorOf(iterable Iterable<T>) : RawCursor<T,EX> from class org.neo4j.kernel.impl.util.Cursors


        @Override
        public Iterator<PropertyContainer> iterator()
        {
            return new Iterator<>()
            {
                private final int size = 2 * value.size() + 1;
                private int index;
                private final NodeValue[] nodes = value.nodes();
                private final RelationshipValue[] relationships = value.relationships();

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

                @Override
                public PropertyContainer next()
                {
                    PropertyContainer propertyContainer;
                    if ( (index & 1) == 0 )
                    {
                        propertyContainer = mapNode( nodes[index >> 1] );
                    }
                    else
                    {
                        propertyContainer = mapRelationship( relationships[index >> 1] );
                    }
                    index++;
                    return propertyContainer;
                }
            };
        }

        @Override
        public Iterator<PropertyContainer> iterator()
        {
            return new Iterator<PropertyContainer>()
            {
                private final int size = 2 * value.size() + 1;
                private int index;
                private final NodeValue[] nodes = value.nodes();
                private final RelationshipValue[] relationships = value.relationships();

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

                @Override
                public PropertyContainer next()
                {
                    PropertyContainer propertyContainer;
                    if ( (index & 1) == 0 )
                    {
                        propertyContainer = mapNode( nodes[index >> 1] );
                    }
                    else
                    {
                        propertyContainer = mapRelationship( relationships[index >> 1] );
                    }
                    index++;
                    return propertyContainer;
                }
            };
        }

Replace Generic With Diamond Iterator<PropertyContainer> with Iterator<> in method public iterator() : Iterator<PropertyContainer> from class org.neo4j.kernel.impl.util.DefaultValueMapper.CoreAPIPath


    private <U, V> Iterable<V> asList( U[] values, Function<U,V> mapper )
    {
        return () -> new Iterator<>()
        {
            private int index;

            @Override
            public boolean hasNext()
            {
                return index < values.length;
            }

            @Override
            public V next()
            {
                return mapper.apply( values[index++] );
            }
        };
    }

    private <U, V> Iterable<V> asList( U[] values, Function<U,V> mapper )
    {
        return () -> new Iterator<V>()
        {
            private int index;

            @Override
            public boolean hasNext()
            {
                return index < values.length;
            }

            @Override
            public V next()
            {
                return mapper.apply( values[index++] );
            }
        };
    }

Replace Generic With Diamond Iterator<V> with Iterator<> in method private asList(values U[], mapper Function<U,V>) : Iterable<V> from class org.neo4j.kernel.impl.util.DefaultValueMapper


    private <U, V> Iterable<V> asReverseList( U[] values, Function<U,V> mapper )
    {
        return () -> new Iterator<>()
        {
            private int index = values.length - 1;

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

            @Override
            public V next()
            {
                return mapper.apply( values[index--] );
            }
        };
    }

    private <U, V> Iterable<V> asReverseList( U[] values, Function<U,V> mapper )
    {
        return () -> new Iterator<V>()
        {
            private int index = values.length - 1;

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

            @Override
            public V next()
            {
                return mapper.apply( values[index--] );
            }
        };
    }

Replace Generic With Diamond Iterator<V> with Iterator<> in method private asReverseList(values U[], mapper Function<U,V>) : Iterable<V> from class org.neo4j.kernel.impl.util.DefaultValueMapper


        @Override
        public Iterator<Pair<String[],String[]>> iterator()
        {
            final Iterator<SchemaDescriptor> iterator = indexMap.keySet().iterator();
            return new Iterator<>()
            {
                @Override
                public boolean hasNext()
                {
                    return iterator.hasNext();
                }

                @Override
                public Pair<String[],String[]> next()
                {
                    SchemaDescriptor next = iterator.next();
                    EntityType type = next.entityType();
                    String[] entityTokens;
                    switch ( type )
                    {
                    case NODE:
                        entityTokens = labels.byIdOrFail( next.getEntityTokenIds() );
                        break;
                    case RELATIONSHIP:
                        entityTokens = relationshipTypes.byIdOrFail( next.getEntityTokenIds() );
                        break;
                    default:
                        throw new IllegalStateException( "Indexing is not supported for EntityType: " + type );
                    }
                    String[] propertyKeyNames = propertyKeys.byIdOrFail( next.getPropertyIds() );
                    return Pair.of( entityTokens, propertyKeyNames );
                }

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

        @Override
        public Iterator<Pair<String[],String[]>> iterator()
        {
            final Iterator<SchemaDescriptor> iterator = indexMap.keySet().iterator();
            return new Iterator<Pair<String[],String[]>>()
            {
                @Override
                public boolean hasNext()
                {
                    return iterator.hasNext();
                }

                @Override
                public Pair<String[],String[]> next()
                {
                    SchemaDescriptor next = iterator.next();
                    EntityType type = next.entityType();
                    String[] entityTokens;
                    switch ( type )
                    {
                    case NODE:
                        entityTokens = labels.byIdOrFail( next.getEntityTokenIds() );
                        break;
                    case RELATIONSHIP:
                        entityTokens = relationshipTypes.byIdOrFail( next.getEntityTokenIds() );
                        break;
                    default:
                        throw new IllegalStateException( "Indexing is not supported for EntityType: " + type );
                    }
                    String[] propertyKeyNames = propertyKeys.byIdOrFail( next.getPropertyIds() );
                    return Pair.of( entityTokens, propertyKeyNames );
                }

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

Replace Generic With Diamond Iterator<Pair<String[],String[]>> with Iterator<> in method public iterator() : Iterator<Pair<String[],String[]>> from class org.neo4j.kernel.impl.util.dbstructure.DbStructureCollector.IndexDescriptorMap


        @Override
        public Iterator<Pair<Integer, String>> iterator()
        {
            final Iterator<Map.Entry<Integer, String>> iterator = forward.entrySet().iterator();
            return new Iterator<>()
            {
                @Override
                public boolean hasNext()
                {
                    return iterator.hasNext();
                }

                @Override
                public Pair<Integer,String> next()
                {
                    Map.Entry<Integer,String> next = iterator.next();
                    return Pair.of( next.getKey(), next.getValue() );
                }

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

        @Override
        public Iterator<Pair<Integer, String>> iterator()
        {
            final Iterator<Map.Entry<Integer, String>> iterator = forward.entrySet().iterator();
            return new Iterator<Pair<Integer, String>>()
            {
                @Override
                public boolean hasNext()
                {
                    return iterator.hasNext();
                }

                @Override
                public Pair<Integer, String> next()
                {
                    Map.Entry<Integer, String> next = iterator.next();
                    return Pair.of( next.getKey(), next.getValue() );
                }

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

Replace Generic With Diamond Iterator<Pair<Integer,String>> with Iterator<> in method public iterator() : Iterator<Pair<Integer,String>> from class org.neo4j.kernel.impl.util.dbstructure.DbStructureCollector.TokenMap