    static DateTimeBuilder<DateTimeValue> builder( Supplier<ZoneId> defaultZone )
    {
        return new DateTimeBuilder<>( defaultZone )
        {
            @Override
            protected boolean supportsTimeZone()
            {
                return true;
            }

            @Override
            protected boolean supportsEpoch()
            {
                return true;
            }

            private final ZonedDateTime defaultZonedDateTime =
                    ZonedDateTime.of( TemporalFields.year.defaultValue, TemporalFields.month.defaultValue,
                                      TemporalFields.day.defaultValue, TemporalFields.hour.defaultValue,
                                      TemporalFields.minute.defaultValue, TemporalFields.second.defaultValue,
                                      TemporalFields.nanosecond.defaultValue, timezone() );

            @Override
            public DateTimeValue buildInternal()
            {
                boolean selectingDate = fields.containsKey( TemporalFields.date );
                boolean selectingTime = fields.containsKey( TemporalFields.time );
                boolean selectingDateTime = fields.containsKey( TemporalFields.datetime );
                boolean selectingEpoch = fields.containsKey( TemporalFields.epochSeconds ) ||
                                         fields.containsKey( TemporalFields.epochMillis );
                boolean selectingTimeZone;
                ZonedDateTime result;
                if ( selectingDateTime )
                {
                    AnyValue dtField = fields.get( TemporalFields.datetime );
                    if ( !(dtField instanceof TemporalValue) )
                    {
                        throw new InvalidArgumentException(
                                String.format( "Cannot construct date time from: %s", dtField ) );
                    }
                    TemporalValue dt = (TemporalValue) dtField;
                    LocalTime timePart = dt.getTimePart( defaultZone ).toLocalTime();
                    ZoneId zoneId = dt.getZoneId( defaultZone );
                    result = ZonedDateTime.of( dt.getDatePart(), timePart, zoneId );
                    selectingTimeZone = dt.supportsTimeZone();
                }
                else if ( selectingEpoch )
                {
                    if ( fields.containsKey( TemporalFields.epochSeconds ) )
                    {
                        AnyValue epochField = fields.get( TemporalFields.epochSeconds );
                        if ( !(epochField instanceof IntegralValue) )
                        {
                            throw new InvalidArgumentException(
                                    String.format( "Cannot construct date time from: %s", epochField ) );
                        }
                        IntegralValue epochSeconds = (IntegralValue) epochField;
                        result = assertValidArgument( () -> ZonedDateTime
                                .ofInstant( Instant.ofEpochMilli( epochSeconds.longValue() * 1000 ), timezone() ) );
                    }
                    else
                    {
                        AnyValue epochField = fields.get( TemporalFields.epochMillis );
                        if ( !(epochField instanceof IntegralValue) )
                        {
                            throw new InvalidArgumentException(
                                    String.format( "Cannot construct date time from: %s", epochField ) );
                        }
                        IntegralValue epochMillis = (IntegralValue) epochField;
                        result = assertValidArgument( () -> ZonedDateTime
                                .ofInstant( Instant.ofEpochMilli( epochMillis.longValue() ), timezone() ) );
                    }
                    selectingTimeZone = false;
                }
                else if ( selectingTime || selectingDate )
                {

                    LocalTime time;
                    ZoneId zoneId;
                    if ( selectingTime )
                    {
                        AnyValue timeField = fields.get( TemporalFields.time );
                        if ( !(timeField instanceof TemporalValue) )
                        {
                            throw new InvalidArgumentException(
                                    String.format( "Cannot construct time from: %s", timeField ) );
                        }
                        TemporalValue t = (TemporalValue) timeField;
                        time = t.getTimePart( defaultZone ).toLocalTime();
                        zoneId = t.getZoneId( defaultZone );
                        selectingTimeZone = t.supportsTimeZone();
                    }
                    else
                    {
                        time = LocalTimeValue.DEFAULT_LOCAL_TIME;
                        zoneId = timezone();
                        selectingTimeZone = false;
                    }
                    LocalDate date;
                    if ( selectingDate )
                    {
                        AnyValue dateField = fields.get( TemporalFields.date );
                        if ( !(dateField instanceof TemporalValue) )
                        {
                            throw new InvalidArgumentException(
                                    String.format( "Cannot construct date from: %s", dateField ) );
                        }
                        TemporalValue t = (TemporalValue) dateField;
                        date = t.getDatePart();
                    }
                    else
                    {
                        date = DateValue.DEFAULT_CALENDER_DATE;
                    }
                    result = ZonedDateTime.of( date, time, zoneId );
                }
                else
                {
                    result = defaultZonedDateTime;
                    selectingTimeZone = false;
                }

                if ( fields.containsKey( TemporalFields.week ) && !selectingDate && !selectingDateTime &&
                     !selectingEpoch )
                {
                    // Be sure to be in the start of the week based year (which can be later than 1st Jan)
                    result = result
                            .with( IsoFields.WEEK_BASED_YEAR,
                                   safeCastIntegral( TemporalFields.year.name(), fields.get( TemporalFields.year ),
                                                     TemporalFields.year.defaultValue ) )
                            .with( IsoFields.WEEK_OF_WEEK_BASED_YEAR, 1 )
                            .with( ChronoField.DAY_OF_WEEK, 1 );
                }

                result = assignAllFields( result );
                if ( timezone != null )
                {
                    if ( ((selectingTime || selectingDateTime) && selectingTimeZone) || selectingEpoch )
                    {
                        try
                        {
                            result = result.withZoneSameInstant( timezone() );
                        }
                        catch ( DateTimeParseException e )
                        {
                            throw new TemporalParseException( e.getMessage(), e.getParsedString(), e.getErrorIndex(), e );
                        }
                    }
                    else
                    {
                        result = result.withZoneSameLocal( timezone() );
                    }
                }
                return datetime( result );
            }

            @Override
            protected DateTimeValue selectDateTime( AnyValue datetime )
            {
                if ( datetime instanceof DateTimeValue )
                {
                    DateTimeValue value = (DateTimeValue) datetime;
                    ZoneId zone = optionalTimezone();
                    return zone == null ? value : new DateTimeValue(
                            ZonedDateTime.of( value.temporal().toLocalDateTime(), zone ) );
                }
                if ( datetime instanceof LocalDateTimeValue )
                {
                    return new DateTimeValue( ZonedDateTime.of(
                            ((LocalDateTimeValue) datetime).temporal(), timezone() ) );
                }
                throw new UnsupportedTemporalUnitException( "Cannot select datetime from: " + datetime );
            }
        };
    }

    static DateTimeBuilder<DateTimeValue> builder( Supplier<ZoneId> defaultZone )
    {
        return new DateTimeBuilder<DateTimeValue>( defaultZone )
        {
            @Override
            protected boolean supportsTimeZone()
            {
                return true;
            }

            @Override
            protected boolean supportsEpoch()
            {
                return true;
            }

            private final ZonedDateTime defaultZonedDateTime =
                    ZonedDateTime.of( TemporalFields.year.defaultValue, TemporalFields.month.defaultValue,
                            TemporalFields.day.defaultValue, TemporalFields.hour.defaultValue,
                            TemporalFields.minute.defaultValue, TemporalFields.second.defaultValue,
                            TemporalFields.nanosecond.defaultValue, timezone() );

            @Override
            public DateTimeValue buildInternal()
            {
                boolean selectingDate = fields.containsKey( TemporalFields.date );
                boolean selectingTime = fields.containsKey( TemporalFields.time );
                boolean selectingDateTime = fields.containsKey( TemporalFields.datetime );
                boolean selectingEpoch = fields.containsKey( TemporalFields.epochSeconds ) ||
                                         fields.containsKey( TemporalFields.epochMillis );
                boolean selectingTimeZone;
                ZonedDateTime result;
                if ( selectingDateTime )
                {
                    AnyValue dtField = fields.get( TemporalFields.datetime );
                    if ( !(dtField instanceof TemporalValue) )
                    {
                        throw new InvalidArgumentException(
                                String.format( "Cannot construct date time from: %s", dtField ) );
                    }
                    TemporalValue dt = (TemporalValue) dtField;
                    LocalTime timePart = dt.getTimePart( defaultZone ).toLocalTime();
                    ZoneId zoneId = dt.getZoneId( defaultZone );
                    result = ZonedDateTime.of( dt.getDatePart(), timePart, zoneId );
                    selectingTimeZone = dt.supportsTimeZone();
                }
                else if ( selectingEpoch )
                {
                    if ( fields.containsKey( TemporalFields.epochSeconds ) )
                    {
                        AnyValue epochField = fields.get( TemporalFields.epochSeconds );
                        if ( !(epochField instanceof IntegralValue) )
                        {
                            throw new InvalidArgumentException(
                                    String.format( "Cannot construct date time from: %s", epochField ) );
                        }
                        IntegralValue epochSeconds = (IntegralValue) epochField;
                        result = assertValidArgument( () -> ZonedDateTime
                                .ofInstant( Instant.ofEpochMilli( epochSeconds.longValue() * 1000 ), timezone() ) );
                    }
                    else
                    {
                        AnyValue epochField = fields.get( TemporalFields.epochMillis );
                        if ( !(epochField instanceof IntegralValue) )
                        {
                            throw new InvalidArgumentException(
                                    String.format( "Cannot construct date time from: %s", epochField ) );
                        }
                        IntegralValue epochMillis = (IntegralValue) epochField;
                        result = assertValidArgument( () -> ZonedDateTime
                                .ofInstant( Instant.ofEpochMilli( epochMillis.longValue() ), timezone() ) );
                    }
                    selectingTimeZone = false;
                }
                else if ( selectingTime || selectingDate )
                {

                    LocalTime time;
                    ZoneId zoneId;
                    if ( selectingTime )
                    {
                        AnyValue timeField = fields.get( TemporalFields.time );
                        if ( !(timeField instanceof TemporalValue) )
                        {
                            throw new InvalidArgumentException(
                                    String.format( "Cannot construct time from: %s", timeField ) );
                        }
                        TemporalValue t = (TemporalValue) timeField;
                        time = t.getTimePart( defaultZone ).toLocalTime();
                        zoneId = t.getZoneId( defaultZone );
                        selectingTimeZone = t.supportsTimeZone();
                    }
                    else
                    {
                        time = LocalTimeValue.DEFAULT_LOCAL_TIME;
                        zoneId = timezone();
                        selectingTimeZone = false;
                    }
                    LocalDate date;
                    if ( selectingDate )
                    {
                        AnyValue dateField = fields.get( TemporalFields.date );
                        if ( !(dateField instanceof TemporalValue) )
                        {
                            throw new InvalidArgumentException(
                                    String.format( "Cannot construct date from: %s", dateField ) );
                        }
                        TemporalValue t = (TemporalValue) dateField;
                        date = t.getDatePart();
                    }
                    else
                    {
                        date = DateValue.DEFAULT_CALENDER_DATE;
                    }
                    result = ZonedDateTime.of( date, time, zoneId );
                }
                else
                {
                    result = defaultZonedDateTime;
                    selectingTimeZone = false;
                }

                if ( fields.containsKey( TemporalFields.week ) && !selectingDate && !selectingDateTime &&
                     !selectingEpoch )
                {
                    // Be sure to be in the start of the week based year (which can be later than 1st Jan)
                    result = result
                            .with( IsoFields.WEEK_BASED_YEAR,
                                    safeCastIntegral( TemporalFields.year.name(), fields.get( TemporalFields.year ),
                                            TemporalFields.year.defaultValue ) )
                            .with( IsoFields.WEEK_OF_WEEK_BASED_YEAR, 1 )
                            .with( ChronoField.DAY_OF_WEEK, 1 );
                }

                result = assignAllFields( result );
                if ( timezone != null )
                {
                    if ( ((selectingTime || selectingDateTime) && selectingTimeZone) || selectingEpoch )
                    {
                        try
                        {
                            result = result.withZoneSameInstant( timezone() );
                        }
                        catch ( DateTimeParseException e )
                        {
                            throw new TemporalParseException( e.getMessage(), e.getParsedString(), e.getErrorIndex(), e );
                        }
                    }
                    else
                    {
                        result = result.withZoneSameLocal( timezone() );
                    }
                }
                return datetime( result );
            }

            @Override
            protected DateTimeValue selectDateTime( AnyValue datetime )
            {
                if ( datetime instanceof DateTimeValue )
                {
                    DateTimeValue value = (DateTimeValue) datetime;
                    ZoneId zone = optionalTimezone();
                    return zone == null ? value : new DateTimeValue(
                            ZonedDateTime.of( value.temporal().toLocalDateTime(), zone ) );
                }
                if ( datetime instanceof LocalDateTimeValue )
                {
                    return new DateTimeValue( ZonedDateTime.of(
                            ((LocalDateTimeValue) datetime).temporal(), timezone() ) );
                }
                throw new UnsupportedTemporalUnitException( "Cannot select datetime from: " + datetime );
            }
        };
    }

Replace Generic With Diamond DateTimeBuilder<DateTimeValue> with DateTimeBuilder<> in method package builder(defaultZone Supplier<ZoneId>) : DateTimeBuilder<DateTimeValue> from class org.neo4j.values.storable.DateTimeValue


    private static StructureBuilder<AnyValue,DurationValue> builder()
    {
        return new DurationBuilder<>()
        {
            @Override
            DurationValue create(
                    AnyValue years,
                    AnyValue months,
                    AnyValue weeks,
                    AnyValue days,
                    AnyValue hours,
                    AnyValue minutes,
                    AnyValue seconds,
                    AnyValue milliseconds,
                    AnyValue microseconds,
                    AnyValue nanoseconds )
            {
                return approximate(
                        safeCastFloatingPoint( "years", years, 0 ) * 12 +
                        safeCastFloatingPoint( "months", months, 0 ),
                        safeCastFloatingPoint( "weeks", weeks, 0 ) * 7 +
                        safeCastFloatingPoint( "days", days, 0 ),
                        safeCastFloatingPoint( "hours", hours, 0 ) * 3600 +
                        safeCastFloatingPoint( "minutes", minutes, 0 ) * 60 +
                        safeCastFloatingPoint( "seconds", seconds, 0 ),
                        safeCastFloatingPoint( "milliseconds", milliseconds, 0 ) * 1_000_000 +
                        safeCastFloatingPoint( "microseconds", microseconds, 0 ) * 1_000 +
                        safeCastFloatingPoint( "nanoseconds", nanoseconds, 0 )
                );
            }
        };
    }

    static StructureBuilder<AnyValue,DurationValue> builder()
    {
        return new DurationBuilder<AnyValue,DurationValue>()
        {
            @Override
            DurationValue create(
                    AnyValue years,
                    AnyValue months,
                    AnyValue weeks,
                    AnyValue days,
                    AnyValue hours,
                    AnyValue minutes,
                    AnyValue seconds,
                    AnyValue milliseconds,
                    AnyValue microseconds,
                    AnyValue nanoseconds )
            {
                return approximate(
                        safeCastFloatingPoint( "years", years, 0 ) * 12 +
                                safeCastFloatingPoint( "months", months, 0 ),
                        safeCastFloatingPoint( "weeks", weeks, 0 ) * 7 +
                                safeCastFloatingPoint( "days", days, 0 ),
                        safeCastFloatingPoint( "hours", hours, 0 ) * 3600 +
                                safeCastFloatingPoint( "minutes", minutes, 0 ) * 60 +
                                safeCastFloatingPoint( "seconds", seconds, 0 ),
                        safeCastFloatingPoint( "milliseconds", milliseconds, 0 ) * 1_000_000 +
                                safeCastFloatingPoint( "microseconds", microseconds, 0 ) * 1_000 +
                                safeCastFloatingPoint( "nanoseconds", nanoseconds, 0 )
                );
            }
        };
    }

Replace Generic With Diamond DurationBuilder<AnyValue,DurationValue> with DurationBuilder<> in method private builder() : StructureBuilder<AnyValue,DurationValue> from class org.neo4j.values.storable.DurationValue


    static DateTimeValue.DateTimeBuilder<LocalDateTimeValue> builder( Supplier<ZoneId> defaultZone )
    {
        return new DateTimeValue.DateTimeBuilder<>( defaultZone )
        {
            @Override
            protected boolean supportsTimeZone()
            {
                return false;
            }

            @Override
            protected boolean supportsEpoch()
            {
                return false;
            }

            @Override
            public LocalDateTimeValue buildInternal()
            {
                boolean selectingDate = fields.containsKey( TemporalFields.date );
                boolean selectingTime = fields.containsKey( TemporalFields.time );
                boolean selectingDateTime = fields.containsKey( TemporalFields.datetime );
                LocalDateTime result;
                if ( selectingDateTime )
                {
                    AnyValue dtField = fields.get( TemporalFields.datetime );
                    if ( !(dtField instanceof TemporalValue) )
                    {
                        throw new InvalidArgumentException( String.format( "Cannot construct local date time from: %s", dtField ) );
                    }
                    TemporalValue dt = (TemporalValue) dtField;
                    result = LocalDateTime.of( dt.getDatePart(), dt.getLocalTimePart() );
                }
                else if ( selectingTime || selectingDate )
                {
                    LocalTime time;
                    if ( selectingTime )
                    {
                        AnyValue timeField = fields.get( TemporalFields.time );
                        if ( !(timeField instanceof TemporalValue) )
                        {
                            throw new InvalidArgumentException( String.format( "Cannot construct local time from: %s", timeField ) );
                        }
                        TemporalValue t = (TemporalValue) timeField;
                        time = t.getLocalTimePart();
                    }
                    else
                    {
                        time = LocalTimeValue.DEFAULT_LOCAL_TIME;
                    }
                    LocalDate date;
                    if ( selectingDate )
                    {
                        AnyValue dateField = fields.get( TemporalFields.date );
                        if ( !(dateField instanceof TemporalValue) )
                        {
                            throw new InvalidArgumentException( String.format( "Cannot construct date from: %s", dateField ) );
                        }
                        TemporalValue t = (TemporalValue) dateField;
                        date = t.getDatePart();
                    }
                    else
                    {
                        date = DateValue.DEFAULT_CALENDER_DATE;
                    }

                    result = LocalDateTime.of( date, time );
                }
                else
                {
                    result = DEFAULT_LOCAL_DATE_TIME;
                }

                if ( fields.containsKey( TemporalFields.week ) && !selectingDate && !selectingDateTime )
                {
                    // Be sure to be in the start of the week based year (which can be later than 1st Jan)
                    result = result
                            .with( IsoFields.WEEK_BASED_YEAR, safeCastIntegral( TemporalFields.year.name(), fields.get( TemporalFields.year ),
                                                                                TemporalFields.year.defaultValue ) )
                            .with( IsoFields.WEEK_OF_WEEK_BASED_YEAR, 1 )
                            .with( ChronoField.DAY_OF_WEEK, 1 );
                }

                result = assignAllFields( result );
                return localDateTime( result );
            }

            private LocalDateTime getLocalDateTimeOf( AnyValue temporal )
            {
                if ( temporal instanceof TemporalValue )
                {
                    TemporalValue v = (TemporalValue) temporal;
                    LocalDate datePart = v.getDatePart();
                    LocalTime timePart = v.getLocalTimePart();
                    return LocalDateTime.of( datePart, timePart );
                }
                throw new InvalidArgumentException( String.format( "Cannot construct date from: %s", temporal ) );
            }

            @Override
            protected LocalDateTimeValue selectDateTime( AnyValue datetime )
            {
                if ( datetime instanceof LocalDateTimeValue )
                {
                    return (LocalDateTimeValue) datetime;
                }
                return localDateTime( getLocalDateTimeOf( datetime ) );
            }
        };
    }

    static DateTimeValue.DateTimeBuilder<LocalDateTimeValue> builder( Supplier<ZoneId> defaultZone )
    {
        return new DateTimeValue.DateTimeBuilder<LocalDateTimeValue>( defaultZone )
        {
            @Override
            protected boolean supportsTimeZone()
            {
                return false;
            }

            @Override
            protected boolean supportsEpoch()
            {
                return false;
            }

            @Override
            public LocalDateTimeValue buildInternal()
            {
                boolean selectingDate = fields.containsKey( TemporalFields.date );
                boolean selectingTime = fields.containsKey( TemporalFields.time );
                boolean selectingDateTime = fields.containsKey( TemporalFields.datetime );
                LocalDateTime result;
                if ( selectingDateTime )
                {
                    AnyValue dtField = fields.get( TemporalFields.datetime );
                    if ( !(dtField instanceof TemporalValue) )
                    {
                        throw new InvalidArgumentException( String.format( "Cannot construct local date time from: %s", dtField ) );
                    }
                    TemporalValue dt = (TemporalValue) dtField;
                    result = LocalDateTime.of( dt.getDatePart(), dt.getLocalTimePart() );
                }
                else if ( selectingTime || selectingDate )
                {
                    LocalTime time;
                    if ( selectingTime )
                    {
                        AnyValue timeField = fields.get( TemporalFields.time );
                        if ( !(timeField instanceof TemporalValue) )
                        {
                            throw new InvalidArgumentException( String.format( "Cannot construct local time from: %s", timeField ) );
                        }
                        TemporalValue t = (TemporalValue) timeField;
                        time = t.getLocalTimePart();
                    }
                    else
                    {
                        time = LocalTimeValue.DEFAULT_LOCAL_TIME;
                    }
                    LocalDate date;
                    if ( selectingDate )
                    {
                        AnyValue dateField = fields.get( TemporalFields.date );
                        if ( !(dateField instanceof TemporalValue) )
                        {
                            throw new InvalidArgumentException( String.format( "Cannot construct date from: %s", dateField ) );
                        }
                        TemporalValue t = (TemporalValue) dateField;
                        date = t.getDatePart();
                    }
                    else
                    {
                        date = DateValue.DEFAULT_CALENDER_DATE;
                    }

                    result = LocalDateTime.of( date, time );
                }
                else
                {
                    result = DEFAULT_LOCAL_DATE_TIME;
                }

                if ( fields.containsKey( TemporalFields.week ) && !selectingDate && !selectingDateTime )
                {
                    // Be sure to be in the start of the week based year (which can be later than 1st Jan)
                    result = result
                            .with( IsoFields.WEEK_BASED_YEAR, safeCastIntegral( TemporalFields.year.name(), fields.get( TemporalFields.year ),
                                    TemporalFields.year.defaultValue ) )
                            .with( IsoFields.WEEK_OF_WEEK_BASED_YEAR, 1 )
                            .with( ChronoField.DAY_OF_WEEK, 1 );
                }

                result = assignAllFields( result );
                return localDateTime( result );
            }

            private LocalDateTime getLocalDateTimeOf( AnyValue temporal )
            {
                if ( temporal instanceof TemporalValue )
                {
                    TemporalValue v = (TemporalValue) temporal;
                    LocalDate datePart = v.getDatePart();
                    LocalTime timePart = v.getLocalTimePart();
                    return LocalDateTime.of( datePart, timePart );
                }
                throw new InvalidArgumentException( String.format( "Cannot construct date from: %s", temporal ) );
            }

            @Override
            protected LocalDateTimeValue selectDateTime( AnyValue datetime )
            {
                if ( datetime instanceof LocalDateTimeValue )
                {
                    return (LocalDateTimeValue) datetime;
                }
                return localDateTime( getLocalDateTimeOf( datetime ) );
            }
        };
    }

Replace Generic With Diamond DateTimeValue.DateTimeBuilder<LocalDateTimeValue> with DateTimeValue.DateTimeBuilder<> in method package builder(defaultZone Supplier<ZoneId>) : DateTimeValue.DateTimeBuilder<LocalDateTimeValue> from class org.neo4j.values.storable.LocalDateTimeValue


    static TimeValue.TimeBuilder<LocalTimeValue> builder( Supplier<ZoneId> defaultZone )
    {
        return new TimeValue.TimeBuilder<>( defaultZone )
        {
            @Override
            protected boolean supportsTimeZone()
            {
                return false;
            }

            @Override
            public LocalTimeValue buildInternal()
            {
                LocalTime result;
                if ( fields.containsKey( TemporalFields.time ) )
                {
                    AnyValue time = fields.get( TemporalFields.time );
                    if ( !(time instanceof TemporalValue) )
                    {
                        throw new InvalidArgumentException( String.format( "Cannot construct local time from: %s", time ) );
                    }
                    result = ((TemporalValue) time).getLocalTimePart();
                }
                else
                {
                    result = DEFAULT_LOCAL_TIME;
                }

                result = assignAllFields( result );
                return localTime( result );
            }

            @Override
            protected LocalTimeValue selectTime(
                    AnyValue time )
            {

                if ( !(time instanceof TemporalValue) )
                {
                    throw new InvalidArgumentException( String.format( "Cannot construct local time from: %s", time ) );
                }
                TemporalValue v = (TemporalValue) time;
                LocalTime lt = v.getLocalTimePart();
                return localTime( lt );
            }
        };
    }

    static TimeValue.TimeBuilder<LocalTimeValue> builder( Supplier<ZoneId> defaultZone )
    {
        return new TimeValue.TimeBuilder<LocalTimeValue>( defaultZone )
        {
            @Override
            protected boolean supportsTimeZone()
            {
                return false;
            }

            @Override
            public LocalTimeValue buildInternal()
            {
                LocalTime result;
                if ( fields.containsKey( TemporalFields.time ) )
                {
                    AnyValue time = fields.get( TemporalFields.time );
                    if ( !(time instanceof TemporalValue) )
                    {
                        throw new InvalidArgumentException( String.format( "Cannot construct local time from: %s", time ) );
                    }
                    result = ((TemporalValue) time).getLocalTimePart();
                }
                else
                {
                    result = DEFAULT_LOCAL_TIME;
                }

                result = assignAllFields( result );
                return localTime( result );
            }

            @Override
            protected LocalTimeValue selectTime(
                    AnyValue time )
            {

                if ( !(time instanceof TemporalValue) )
                {
                    throw new InvalidArgumentException( String.format( "Cannot construct local time from: %s", time ) );
                }
                TemporalValue v = (TemporalValue) time;
                LocalTime lt = v.getLocalTimePart();
                return localTime( lt );
            }
        };
    }

Replace Generic With Diamond TimeValue.TimeBuilder<LocalTimeValue> with TimeValue.TimeBuilder<> in method package builder(defaultZone Supplier<ZoneId>) : TimeValue.TimeBuilder<LocalTimeValue> from class org.neo4j.values.storable.LocalTimeValue


    static TimeBuilder<TimeValue> builder( Supplier<ZoneId> defaultZone )
    {
        return new TimeBuilder<>( defaultZone )
        {
            @Override
            protected boolean supportsTimeZone()
            {
                return true;
            }

            @Override
            public TimeValue buildInternal()
            {
                boolean selectingTime = fields.containsKey( TemporalFields.time );
                boolean selectingTimeZone;
                OffsetTime result;
                if ( selectingTime )
                {
                    AnyValue time = fields.get( TemporalFields.time );
                    if ( !(time instanceof TemporalValue) )
                    {
                        throw new InvalidArgumentException( String.format( "Cannot construct time from: %s", time ) );
                    }
                    TemporalValue t = (TemporalValue) time;
                    result = t.getTimePart( defaultZone );
                    selectingTimeZone = t.supportsTimeZone();
                }
                else
                {
                    ZoneId timezone = timezone();
                    if ( !(timezone instanceof ZoneOffset) )
                    {
                        timezone = assertValidArgument( () -> ZonedDateTime.ofInstant( Instant.now(), timezone() ) ).getOffset();
                    }

                    result = defaultTime( timezone );
                    selectingTimeZone = false;
                }

                result = assignAllFields( result );
                if ( timezone != null )
                {
                    ZoneOffset currentOffset = assertValidArgument( () -> ZonedDateTime.ofInstant( Instant.now(), timezone() ) ).getOffset();
                    if ( selectingTime && selectingTimeZone )
                    {
                        result = result.withOffsetSameInstant( currentOffset );
                    }
                    else
                    {
                        result = result.withOffsetSameLocal( currentOffset );
                    }
                }
                return time( result );
            }

            @Override
            protected TimeValue selectTime(
                    AnyValue temporal )
            {
                if ( !(temporal instanceof TemporalValue) )
                {
                    throw new InvalidArgumentException( String.format( "Cannot construct time from: %s", temporal ) );
                }
                if ( temporal instanceof TimeValue &&
                     timezone == null )
                {
                    return (TimeValue) temporal;
                }

                TemporalValue v = (TemporalValue) temporal;
                OffsetTime time = v.getTimePart( defaultZone );
                if ( timezone != null )
                {
                    ZoneOffset currentOffset = assertValidArgument( () -> ZonedDateTime.ofInstant( Instant.now(), timezone() ) ).getOffset();
                    time = time.withOffsetSameInstant( currentOffset );
                }
                return time( time );
            }
        };
    }

    static TimeBuilder<TimeValue> builder( Supplier<ZoneId> defaultZone )
    {
        return new TimeBuilder<TimeValue>( defaultZone )
        {
            @Override
            protected boolean supportsTimeZone()
            {
                return true;
            }

            @Override
            public TimeValue buildInternal()
            {
                boolean selectingTime = fields.containsKey( TemporalFields.time );
                boolean selectingTimeZone;
                OffsetTime result;
                if ( selectingTime )
                {
                    AnyValue time = fields.get( TemporalFields.time );
                    if ( !(time instanceof TemporalValue) )
                    {
                        throw new InvalidArgumentException( String.format( "Cannot construct time from: %s", time ) );
                    }
                    TemporalValue t = (TemporalValue) time;
                    result = t.getTimePart( defaultZone );
                    selectingTimeZone = t.supportsTimeZone();
                }
                else
                {
                    ZoneId timezone = timezone();
                    if ( !(timezone instanceof ZoneOffset) )
                    {
                        timezone = assertValidArgument( () -> ZonedDateTime.ofInstant( Instant.now(), timezone() ) ).getOffset();
                    }

                    result = defaultTime( timezone );
                    selectingTimeZone = false;
                }

                result = assignAllFields( result );
                if ( timezone != null )
                {
                    ZoneOffset currentOffset = assertValidArgument( () -> ZonedDateTime.ofInstant( Instant.now(), timezone() ) ).getOffset();
                    if ( selectingTime && selectingTimeZone )
                    {
                        result = result.withOffsetSameInstant( currentOffset );
                    }
                    else
                    {
                        result = result.withOffsetSameLocal( currentOffset );
                    }
                }
                return time( result );
            }
            @Override
            protected TimeValue selectTime(
                    AnyValue temporal )
            {
                if ( !(temporal instanceof TemporalValue) )
                {
                    throw new InvalidArgumentException( String.format( "Cannot construct time from: %s", temporal ) );
                }
                if ( temporal instanceof TimeValue &&
                        timezone == null )
                {
                    return (TimeValue) temporal;
                }

                TemporalValue v = (TemporalValue) temporal;
                OffsetTime time = v.getTimePart( defaultZone );
                if ( timezone != null )
                {
                    ZoneOffset currentOffset = assertValidArgument( () -> ZonedDateTime.ofInstant( Instant.now(), timezone() ) ).getOffset();
                    time = time.withOffsetSameInstant( currentOffset );
                }
                return time( time );
            }
        };
    }

Replace Generic With Diamond TimeBuilder<TimeValue> with TimeBuilder<> in method package builder(defaultZone Supplier<ZoneId>) : TimeBuilder<TimeValue> from class org.neo4j.values.storable.TimeValue


        @Override
        public Iterable<String> keySet()
        {
            return () -> new Iterator<>()
            {
                private Iterator<String> internal = map.keySet().iterator();
                private int index;

                @Override
                public boolean hasNext()
                {
                    if ( internal.hasNext() )
                    {
                        return true;
                    }
                    else
                    {
                        return index < updatedKeys.length;
                    }
                }

                @Override
                public String next()
                {
                    if ( internal.hasNext() )
                    {
                        return internal.next();
                    }
                    else if ( index < updatedKeys.length )
                    {
                        return updatedKeys[index++];
                    }
                    else
                    {
                        throw new NoSuchElementException();
                    }
                }
            };
        }

        @Override
        public Iterable<String> keySet()
        {
            return () -> new Iterator<String>()
            {
                private Iterator<String> internal = map.keySet().iterator();
                private int index;

                @Override
                public boolean hasNext()
                {
                    if ( internal.hasNext() )
                    {
                        return true;
                    }
                    else
                    {
                        return index < updatedKeys.length;
                    }
                }

                @Override
                public String next()
                {
                    if ( internal.hasNext() )
                    {
                        return internal.next();
                    }
                    else if ( index < updatedKeys.length )
                    {
                        return updatedKeys[index++];
                    }
                    else
                    {
                        throw new NoSuchElementException();
                    }
                }
            };
        }

Replace Generic With Diamond Iterator<String> with Iterator<> in method public keySet() : Iterable<String> from class org.neo4j.values.virtual.MapValue.UpdatedMapValue


        @Override
        public Iterable<String> keySet()
        {
           return () -> new PrefetchingIterator<>()
           {
               private int mapIndex;
               private Iterator<String> internal;

               @Override
               protected String fetchNextOrNull()
               {
                   while ( mapIndex < maps.length )
                   {
                       if ( internal == null || !internal.hasNext() )
                       {
                           internal = maps[mapIndex++].keySet().iterator();
                       }

                       if ( internal.hasNext() )
                       {
                           return internal.next();
                       }
                   }
                   return null;
               }
           };
        }

        @Override
        public Iterable<String> keySet()
        {
           return () -> new PrefetchingIterator<String>()
           {
               private int mapIndex;
               private Iterator<String> internal;

               @Override
               protected String fetchNextOrNull()
               {
                   while ( mapIndex < maps.length )
                   {
                       if ( internal == null || !internal.hasNext() )
                       {
                           internal = maps[mapIndex++].keySet().iterator();
                       }

                       if ( internal.hasNext() )
                       {
                           return internal.next();
                       }
                   }
                   return null;
               }
           };
        }

Replace Generic With Diamond PrefetchingIterator<String> with PrefetchingIterator<> in method public keySet() : Iterable<String> from class org.neo4j.values.virtual.MapValue.CombinedMapValue


    @Test
    void evaluateState()
    {
        /*
         * (a)-1->(b)-2->(c)-3->(d)
         *   \           ^
         *    4         6
         *    (e)-5->(f)
         */
        createGraph( "a TO b", "b TO c", "c TO d", "a TO e", "e TO f", "f TO c" );

        try ( Transaction tx = beginTx() )
        {
            PathEvaluator<Integer> evaluator = new PathEvaluator.Adapter<>()
            {
                @Override
                public Evaluation evaluate( Path path, BranchState<Integer> state )
                {
                    return ofIncludes( path.endNode().getProperty( "name" ).equals( "c" ) && state.getState() == 3 );
                }
            };

            expectPaths( tx.traversalDescription().uniqueness( Uniqueness.NODE_PATH ).expand(
                    new RelationshipWeightExpander(), new InitialBranchState.State<>( 1, 1 ) )
                    .evaluator( evaluator ).traverse( getNodeWithName( "a" ) ), "a,b,c" );
            tx.commit();
        }
    }

    @Test
    void evaluateState()
    {
        /*
         * (a)-1->(b)-2->(c)-3->(d)
         *   \           ^
         *    4         6
         *    (e)-5->(f)
         */
        createGraph( "a TO b", "b TO c", "c TO d", "a TO e", "e TO f", "f TO c" );

        try ( Transaction tx = beginTx() )
        {
            PathEvaluator<Integer> evaluator = new PathEvaluator.Adapter<Integer>()
            {
                @Override
                public Evaluation evaluate( Path path, BranchState<Integer> state )
                {
                    return ofIncludes( path.endNode().getProperty( "name" ).equals( "c" ) && state.getState() == 3 );
                }
            };

            expectPaths( getGraphDb().traversalDescription().uniqueness( Uniqueness.NODE_PATH ).expand(
                    new RelationshipWeightExpander(), new InitialBranchState.State<>( 1, 1 ) )
                    .evaluator( evaluator ).traverse( getNodeWithName( "a" ) ), "a,b,c" );
            tx.commit();
        }
    }

Replace Generic With Diamond PathEvaluator.Adapter<Integer> with PathEvaluator.Adapter<> in method package evaluateState() : void from class org.neo4j.kernel.impl.traversal.TestBranchState


    private static Matcher<List<?>> hasSize( final int size )
    {
        return new TypeSafeMatcher<>()
        {
            @Override
            protected boolean matchesSafely( List<?> item )
            {
                return item.size() == size;
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendText( "List with size=" ).appendValue( size );
            }
        };
    }

    private static Matcher<List<?>> hasSize( final int size )
    {
        return new TypeSafeMatcher<List<?>>()
        {
            @Override
            protected boolean matchesSafely( List<?> item )
            {
                return item.size() == size;
            }

            @Override
            public void describeTo( Description description )
            {
                description.appendText( "List with size=" ).appendValue( size );
            }
        };
    }

Replace Generic With Diamond TypeSafeMatcher<List<?>> with TypeSafeMatcher<> in method private hasSize(size int) : Matcher<List<?>> from class org.neo4j.kernel.api.impl.schema.UniqueIndexApplicationIT


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

    private static <T extends PropertyContainer> Function<GraphDatabaseService, Object> propertyRead(
            Class<T> type, final T entity, final String key )
    {
        return new FailureRewrite<Object>( type.getSimpleName() + ".getProperty()" )
        {
            @Override
            Object perform( GraphDatabaseService graphDb )
            {
                return entity.getProperty( key );
            }
        };
    }

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


    public static ListRepresentation string( Iterable<String> values )
    {
        return new ListRepresentation( RepresentationType.STRING, new IterableWrapper<>( values )
        {
            @Override
            protected Representation underlyingObjectToObject( String value )
            {
                return ValueRepresentation.string( value );
            }
        } );
    }

    public static ListRepresentation string( Iterable<String> values )
    {
        return new ListRepresentation( RepresentationType.STRING, new IterableWrapper<Representation, String>(
                values )
        {
            @Override
            protected Representation underlyingObjectToObject( String value )
            {
                return ValueRepresentation.string( value );
            }
        } );
    }

Replace Generic With Diamond ListRepresentation with ListRepresentation in method public string(values Iterable<String>) : ListRepresentation from class org.neo4j.server.rest.repr.ListRepresentation


    public static ListRepresentation point( Iterable<Point> values )
    {
        return new ListRepresentation( RepresentationType.POINT, new IterableWrapper<>( values )
        {
            @Override
            protected Representation underlyingObjectToObject( Point value )
            {
                return ValueRepresentation.point( value );
            }
        } );
    }

    public static ListRepresentation point( Iterable<Point> values )
    {
        return new ListRepresentation( RepresentationType.POINT, new IterableWrapper<Representation, Point>(
                values )
        {
            @Override
            protected Representation underlyingObjectToObject( Point value )
            {
                return ValueRepresentation.point( value );
            }
        } );
    }

Replace Generic With Diamond ListRepresentation with ListRepresentation in method public point(values Iterable<Point>) : ListRepresentation from class org.neo4j.server.rest.repr.ListRepresentation


    public static ListRepresentation temporal( Iterable<Temporal> values )
    {
        return new ListRepresentation( RepresentationType.TEMPORAL, new IterableWrapper<>( values )
        {
            @Override
            protected Representation underlyingObjectToObject( Temporal value )
            {
                return ValueRepresentation.temporal( value );
            }
        } );
    }

    public static ListRepresentation temporal( Iterable<Temporal> values )
    {
        return new ListRepresentation( RepresentationType.TEMPORAL, new IterableWrapper<Representation, Temporal>(
                values )
        {
            @Override
            protected Representation underlyingObjectToObject( Temporal value )
            {
                return ValueRepresentation.temporal( value );
            }
        } );
    }

Replace Generic With Diamond ListRepresentation with ListRepresentation in method public temporal(values Iterable<Temporal>) : ListRepresentation from class org.neo4j.server.rest.repr.ListRepresentation


    public static ListRepresentation temporalAmount( Iterable<TemporalAmount> values )
    {
        return new ListRepresentation( RepresentationType.TEMPORAL_AMOUNT, new IterableWrapper<>( values )
        {
            @Override
            protected Representation underlyingObjectToObject( TemporalAmount value )
            {
                return ValueRepresentation.temporalAmount( value );
            }
        } );
    }

    public static ListRepresentation temporalAmount( Iterable<TemporalAmount> values )
    {
        return new ListRepresentation( RepresentationType.TEMPORAL_AMOUNT, new IterableWrapper<Representation, TemporalAmount>(
                values )
        {
            @Override
            protected Representation underlyingObjectToObject( TemporalAmount value )
            {
                return ValueRepresentation.temporalAmount( value );
            }
        } );
    }

Replace Generic With Diamond ListRepresentation with ListRepresentation in method public temporalAmount(values Iterable<TemporalAmount>) : ListRepresentation from class org.neo4j.server.rest.repr.ListRepresentation


    public static ListRepresentation relationshipTypes( Iterable<RelationshipType> types )
    {
        return new ListRepresentation( RepresentationType.RELATIONSHIP_TYPE, new IterableWrapper<>( types )
        {
            @Override
            protected Representation underlyingObjectToObject( RelationshipType value )
            {
                return ValueRepresentation.relationshipType( value );
            }
        } );
    }

    public static ListRepresentation relationshipTypes( Iterable<RelationshipType> types )
    {
        return new ListRepresentation( RepresentationType.RELATIONSHIP_TYPE,
                new IterableWrapper<Representation, RelationshipType>( types )
                {
                    @Override
                    protected Representation underlyingObjectToObject( RelationshipType value )
                    {
                        return ValueRepresentation.relationshipType( value );
                    }
                } );
    }

Replace Generic With Diamond ListRepresentation with ListRepresentation in method public relationshipTypes(types Iterable<RelationshipType>) : ListRepresentation from class org.neo4j.server.rest.repr.ListRepresentation


    public static ListRepresentation numbers( final long... values )
    {
        return new ListRepresentation( RepresentationType.LONG, (Iterable<ValueRepresentation>) () -> new PrefetchingIterator<>()
        {
            int pos;

            @Override
            protected ValueRepresentation fetchNextOrNull()
            {
                if ( pos >= values.length )
                {
                    return null;
                }
                return ValueRepresentation.number( values[pos++] );
            }
        } );
    }

    public static ListRepresentation numbers( final long... values )
    {
        return new ListRepresentation( RepresentationType.LONG, (Iterable<ValueRepresentation>) () ->
                new PrefetchingIterator<ValueRepresentation>()
                {
                    int pos;

                    @Override
                    protected ValueRepresentation fetchNextOrNull()
                    {
                        if ( pos >= values.length )
                        {
                            return null;
                        }
                        return ValueRepresentation.number( values[pos++] );
                    }
                } );
    }

Replace Generic With Diamond PrefetchingIterator<ValueRepresentation> with PrefetchingIterator<> in method public numbers(values long...) : ListRepresentation from class org.neo4j.server.rest.repr.ListRepresentation


    public static ListRepresentation numbers( final double[] values )
    {
        return new ListRepresentation( RepresentationType.DOUBLE,
                (Iterable<ValueRepresentation>) () -> new PrefetchingIterator<>()
                {
                    int pos;

                    @Override
                    protected ValueRepresentation fetchNextOrNull()
                    {
                        if ( pos >= values.length )
                        {
                            return null;
                        }
                        return ValueRepresentation.number( values[pos++] );
                    }
                } );
    }

    public static ListRepresentation numbers( final double[] values )
    {
        return new ListRepresentation( RepresentationType.DOUBLE,
                (Iterable<ValueRepresentation>) () -> new PrefetchingIterator<ValueRepresentation>()
                {
                    int pos;

                    @Override
                    protected ValueRepresentation fetchNextOrNull()
                    {
                        if ( pos >= values.length )
                        {
                            return null;
                        }
                        return ValueRepresentation.number( values[pos++] );
                    }
                } );
    }

Replace Generic With Diamond PrefetchingIterator<ValueRepresentation> with PrefetchingIterator<> in method public numbers(values double[]) : ListRepresentation from class org.neo4j.server.rest.repr.ListRepresentation


    @Mapping( "metadata" )
    public MapRepresentation metadata()
    {
        if ( isDeleted() )
        {
            return new MapRepresentation( map( "id", node.getId(), "deleted", Boolean.TRUE ), databaseService );
        }
        else
        {
            Collection<String> labels = Iterables.asCollection( new IterableWrapper<>( node.getLabels() )
            {
                @Override
                protected String underlyingObjectToObject( Label label )
                {
                    return label.name();
                }
            } );
            return new MapRepresentation( map( "id", node.getId(), "labels", labels ), databaseService );
        }
    }

    @Mapping( "metadata" )
    public MapRepresentation metadata()
    {
        if ( isDeleted() )
        {
            return new MapRepresentation( map( "id", node.getId(), "deleted", Boolean.TRUE ) );
        }
        else
        {
            Collection<String> labels = Iterables.asCollection( new IterableWrapper<String,Label>( node.getLabels() )
            {
                @Override
                protected String underlyingObjectToObject( Label label )
                {
                    return label.name();
                }
            } );
            return new MapRepresentation( map( "id", node.getId(), "labels", labels ) );
        }
    }

Replace Generic With Diamond IterableWrapper<String,Label> with IterableWrapper<> in method public metadata() : MapRepresentation from class org.neo4j.server.rest.repr.NodeRepresentation


    /**
     * Create a raw iterator from the provided {@link ThrowingSupplier} - the iterator will end
     * when the supplier returns null.
     */
    static <T, EX extends Exception> RawIterator<T, EX> from( ThrowingSupplier<T, EX> supplier )
    {
        return new AbstractPrefetchingRawIterator<>()
        {
            @Override
            protected T fetchNextOrNull() throws EX
            {
                return supplier.get();
            }
        };
    }

    /**
     * Create a raw iterator from the provided {@link ThrowingSupplier} - the iterator will end
     * when the supplier returns null.
     */
    static <T, EX extends Exception> RawIterator<T, EX> from( ThrowingSupplier<T, EX> supplier )
    {
        return new AbstractPrefetchingRawIterator<T,EX>()
        {
            @Override
            protected T fetchNextOrNull() throws EX
            {
                return supplier.get();
            }
        };
    }

Replace Generic With Diamond AbstractPrefetchingRawIterator<T,EX> with AbstractPrefetchingRawIterator<> in method public from(supplier ThrowingSupplier<T,EX>) : RawIterator<T,EX> from class org.neo4j.collection.RawIterator


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

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

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

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

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

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

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

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

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

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

Replace Generic With Diamond Iterator<T> with Iterator<> in method public append(item C, iterable Iterable<T>) : Iterable<T> from class org.neo4j.internal.helpers.collection.Iterables


    /**
     * Create a new pair of objects.
     *
     * @param first the first object in the pair.
     * @param other the other object in the pair.
     * @param <T1> the type of the first object in the pair
     * @param <T2> the type of the second object in the pair
     * @return a new pair of the two parameters.
     */
    public static <T1, T2> Pair<T1,T2> pair( final T1 first, final T2 other )
    {
        return new Pair<>()
        {
            @Override
            public T1 first()
            {
                return first;
            }

            @Override
            public T2 other()
            {
                return other;
            }
        };
    }

    /**
     * Create a new pair of objects.
     *
     * @param first the first object in the pair.
     * @param other the other object in the pair.
     * @param <T1> the type of the first object in the pair
     * @param <T2> the type of the second object in the pair
     * @return a new pair of the two parameters.
     */
    public static <T1, T2> Pair<T1,T2> pair( final T1 first, final T2 other )
    {
        return new Pair<T1,T2>()
        {
            @Override
            public T1 first()
            {
                return first;
            }

            @Override
            public T2 other()
            {
                return other;
            }
        };
    }

Replace Generic With Diamond Pair<T1,T2> with Pair<> in method public pair(first T1, other T2) : Pair<T1,T2> from class org.neo4j.internal.helpers.collection.Pair


    @Test
    void safeForAllShouldConsumeAllSubjectsRegardlessOfSuccess()
    {
        // given
        List<String> seenSubjects = new ArrayList<>();
        List<String> failedSubjects = new ArrayList<>();
        ThrowingConsumer<String,RuntimeException> consumer = s ->
        {
            seenSubjects.add( s );

            // Fail every other
            if ( seenSubjects.size() % 2 == 1 )
            {
                failedSubjects.add( s );
                throw new RuntimeException( s );
            }
        };
        Iterable<String> subjects = asList( "1", "2", "3", "4", "5" );

        // when
        try
        {
            Iterables.safeForAll( consumer, subjects );
            fail( "Should have thrown exception" );
        }
        catch ( RuntimeException e )
        {
            // then good
            assertEquals( subjects, seenSubjects );
            Iterator<String> failed = failedSubjects.iterator();
            assertTrue( failed.hasNext() );
            assertEquals( e.getMessage(), failed.next() );
            for ( Throwable suppressed : e.getSuppressed() )
            {
                assertTrue( failed.hasNext() );
                assertEquals( suppressed.getMessage(), failed.next() );
            }
            assertFalse( failed.hasNext() );
        }
    }

    @Test
    void safeForAllShouldConsumeAllSubjectsRegardlessOfSuccess()
    {
        // given
        List<String> seenSubjects = new ArrayList<>();
        List<String> failedSubjects = new ArrayList<>();
        ThrowingConsumer<String,RuntimeException> consumer = new ThrowingConsumer<String,RuntimeException>()
        {
            @Override
            public void accept( String s )
            {
                seenSubjects.add( s );

                // Fail every other
                if ( seenSubjects.size() % 2 == 1 )
                {
                    failedSubjects.add( s );
                    throw new RuntimeException( s );
                }
            }
        };
        Iterable<String> subjects = asList( "1", "2", "3", "4", "5" );

        // when
        try
        {
            Iterables.safeForAll( consumer, subjects );
            fail( "Should have thrown exception" );
        }
        catch ( RuntimeException e )
        {
            // then good
            assertEquals( subjects, seenSubjects );
            Iterator<String> failed = failedSubjects.iterator();
            assertTrue( failed.hasNext() );
            assertEquals( e.getMessage(), failed.next() );
            for ( Throwable suppressed : e.getSuppressed() )
            {
                assertTrue( failed.hasNext() );
                assertEquals( suppressed.getMessage(), failed.next() );
            }
            assertFalse( failed.hasNext() );
        }
    }

Replace Anonymous With Lambda org.neo4j.internal.helpers.collection.IterablesTest.safeForAllShouldConsumeAllSubjectsRegardlessOfSuccess.consumer.new ThrowingConsumer<String,RuntimeException> with s -> {seenSubjects.add(s); in method package safeForAllShouldConsumeAllSubjectsRegardlessOfSuccess() : void from class org.neo4j.internal.helpers.collection.IterablesTest


    @Test
    void shouldResizeTheCache()
    {
        final Set<String> cleaned = new HashSet<>();
        LruCache<Integer, String> cache = new LruCache<>( "TestCache", 3 )
        {
            @Override
            public void elementCleaned( String element )
            {
                cleaned.add( element );
            }
        };

        String s1 = "1";
        Integer key1 = 1;
        String s2 = "2";
        Integer key2 = 2;
        String s3 = "3";
        Integer key3 = 3;
        String s4 = "4";
        Integer key4 = 4;
        String s5 = "5";
        Integer key5 = 5;

        cache.put( key1, s1 );
        cache.put( key2, s2 );
        cache.put( key3, s3 );
        cache.get( key2 );

        assertEquals( Set.of( new Integer[]{key1, key2, key3} ), cache.keySet() );
        assertEquals( cache.maxSize(), cache.size() );

        cache.resize( 5 );

        assertEquals( 5, cache.maxSize() );
        assertEquals( 3, cache.size() );
        assertTrue( cleaned.isEmpty() );

        cache.put( key4, s4 );

        assertEquals( Set.of( new Integer[]{key1, key2, key3, key4} ), cache.keySet() );

        cache.put( key5, s5 );

        assertEquals( Set.of( new Integer[]{key1, key2, key3, key4, key5} ), cache.keySet() );
        assertEquals( cache.maxSize(), cache.size() );

        cache.resize( 4 );

        assertEquals( Set.of( new Integer[]{key2, key3, key4, key5} ), cache.keySet() );
        assertEquals( cache.maxSize(), cache.size() );
        assertEquals( Set.of( new String[]{s1} ), cleaned );

        cleaned.clear();

        cache.resize( 3 );

        assertEquals( Set.of( new Integer[]{key2, key4, key5} ), cache.keySet() );
        assertEquals( 3, cache.maxSize() );
        assertEquals( 3, cache.size() );
        assertEquals( Set.of( new String[]{s3} ), cleaned );
    }

    @Test
    void shouldResizeTheCache()
    {
        final Set<String> cleaned = new HashSet<>();
        LruCache<Integer, String> cache = new LruCache<Integer, String>( "TestCache", 3 )
        {
            @Override
            public void elementCleaned( String element )
            {
                cleaned.add( element );
            }
        };

        String s1 = "1";
        Integer key1 = 1;
        String s2 = "2";
        Integer key2 = 2;
        String s3 = "3";
        Integer key3 = 3;
        String s4 = "4";
        Integer key4 = 4;
        String s5 = "5";
        Integer key5 = 5;

        cache.put( key1, s1 );
        cache.put( key2, s2 );
        cache.put( key3, s3 );
        cache.get( key2 );

        assertEquals( Set.of( new Integer[]{key1, key2, key3} ), cache.keySet() );
        assertEquals( cache.maxSize(), cache.size() );

        cache.resize( 5 );

        assertEquals( 5, cache.maxSize() );
        assertEquals( 3, cache.size() );
        assertTrue( cleaned.isEmpty() );

        cache.put( key4, s4 );

        assertEquals( Set.of( new Integer[]{key1, key2, key3, key4} ), cache.keySet() );

        cache.put( key5, s5 );

        assertEquals( Set.of( new Integer[]{key1, key2, key3, key4, key5} ), cache.keySet() );
        assertEquals( cache.maxSize(), cache.size() );

        cache.resize( 4 );

        assertEquals( Set.of( new Integer[]{key2, key3, key4, key5} ), cache.keySet() );
        assertEquals( cache.maxSize(), cache.size() );
        assertEquals( Set.of( new String[]{s1} ), cleaned );

        cleaned.clear();

        cache.resize( 3 );

        assertEquals( Set.of( new Integer[]{key2, key4, key5} ), cache.keySet() );
        assertEquals( 3, cache.maxSize() );
        assertEquals( 3, cache.size() );
        assertEquals( Set.of( new String[]{s3} ), cleaned );
    }

Replace Generic With Diamond LruCache<Integer,String> with LruCache<> in method package shouldResizeTheCache() : void from class org.neo4j.internal.helpers.collection.LruCacheTest


    @Test
    void shouldClear()
    {
        final Set<String> cleaned = new HashSet<>();
        LruCache<Integer, String> cache = new LruCache<>( "TestCache", 3 )
        {
            @Override
            public void elementCleaned( String element )
            {
                cleaned.add( element );
            }
        };

        String s1 = "1";
        Integer key1 = 1;
        String s2 = "2";
        Integer key2 = 2;
        String s3 = "3";
        Integer key3 = 3;
        String s4 = "4";
        Integer key4 = 4;
        String s5 = "5";
        Integer key5 = 5;

        cache.put( key1, s1 );
        cache.put( key2, s2 );
        cache.put( key3, s3 );
        cache.get( key2 );

        assertEquals( Set.of( new Integer[]{key1, key2, key3} ), cache.keySet() );
        assertEquals( cache.maxSize(), cache.size() );

        cache.resize( 5 );

        assertEquals( 5, cache.maxSize() );
        assertEquals( 3, cache.size() );

        cache.put( key4, s4 );

        assertEquals( Set.of( new Integer[]{key1, key2, key3, key4} ), cache.keySet() );

        cache.put( key5, s5 );

        assertEquals( Set.of( new Integer[]{key1, key2, key3, key4, key5} ), cache.keySet() );
        assertEquals( cache.maxSize(), cache.size() );

        cache.clear( );

        assertEquals( 0, cache.size() );
        assertEquals( Set.of( new String[]{s1, s2, s3, s4, s5} ), cleaned );
    }

    @Test
    void shouldClear()
    {
        final Set<String> cleaned = new HashSet<>();
        LruCache<Integer, String> cache = new LruCache<Integer, String>( "TestCache", 3 )
        {
            @Override
            public void elementCleaned( String element )
            {
                cleaned.add( element );
            }
        };

        String s1 = "1";
        Integer key1 = 1;
        String s2 = "2";
        Integer key2 = 2;
        String s3 = "3";
        Integer key3 = 3;
        String s4 = "4";
        Integer key4 = 4;
        String s5 = "5";
        Integer key5 = 5;

        cache.put( key1, s1 );
        cache.put( key2, s2 );
        cache.put( key3, s3 );
        cache.get( key2 );

        assertEquals( Set.of( new Integer[]{key1, key2, key3} ), cache.keySet() );
        assertEquals( cache.maxSize(), cache.size() );

        cache.resize( 5 );

        assertEquals( 5, cache.maxSize() );
        assertEquals( 3, cache.size() );

        cache.put( key4, s4 );

        assertEquals( Set.of( new Integer[]{key1, key2, key3, key4} ), cache.keySet() );

        cache.put( key5, s5 );

        assertEquals( Set.of( new Integer[]{key1, key2, key3, key4, key5} ), cache.keySet() );
        assertEquals( cache.maxSize(), cache.size() );

        cache.clear( );

        assertEquals( 0, cache.size() );
        assertEquals( Set.of( new String[]{s1, s2, s3, s4, s5} ), cleaned );
    }

Replace Generic With Diamond LruCache<Integer,String> with LruCache<> in method package shouldClear() : void from class org.neo4j.internal.helpers.collection.LruCacheTest


    @Override
    public Iterator<T> iterator()
    {
        return new Iterator<>()
        {
            @Override
            public boolean hasNext()
            {
                return pos == 0 || iterator.hasNext();
            }

            @Override
            public T next()
            {
                if ( pos < 0 )
                {
                    throw new NoSuchElementException();
                }
                return pos++ == 0 ? first : iterator.next();
            }

            @Override
            public void remove()
            {

            }
        };
    }

    @Override
    public Iterator<T> iterator()
    {
        return new Iterator<T>()
        {
            @Override
            public boolean hasNext()
            {
                return pos == 0 || iterator.hasNext();
            }

            @Override
            public T next()
            {
                if ( pos < 0 )
                {
                    throw new NoSuchElementException();
                }
                return pos++ == 0 ? first : iterator.next();
            }

            @Override
            public void remove()
            {

            }
        };
    }

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


    public static Iterator<Long> asIterator( final long... array )
    {
        return new PrefetchingIterator<>()
        {
            private int index;

            @Override
            protected Long fetchNextOrNull()
            {
                try
                {
                    return index < array.length ? array[index] : null;
                }
                finally
                {
                    index++;
                }
            }
        };
    }

    public static Iterator<Long> asIterator( final long... array )
    {
        return new PrefetchingIterator<Long>()
        {
            private int index;

            @Override
            protected Long fetchNextOrNull()
            {
                try
                {
                    return index < array.length ? array[index] : null;
                }
                finally
                {
                    index++;
                }
            }
        };
    }

Replace Generic With Diamond PrefetchingIterator<Long> with PrefetchingIterator<> in method public asIterator(array long...) : Iterator<Long> from class org.neo4j.internal.helpers.collection.Iterators


    public static Iterator<Integer> asIterator( final int... array )
    {
        return new PrefetchingIterator<>()
        {
            private int index;

            @Override
            protected Integer fetchNextOrNull()
            {
                try
                {
                    return index < array.length ? array[index] : null;
                }
                finally
                {
                    index++;
                }
            }
        };
    }

    public static Iterator<Integer> asIterator( final int... array )
    {
        return new PrefetchingIterator<Integer>()
        {
            private int index;

            @Override
            protected Integer fetchNextOrNull()
            {
                try
                {
                    return index < array.length ? array[index] : null;
                }
                finally
                {
                    index++;
                }
            }
        };
    }

Replace Generic With Diamond PrefetchingIterator<Integer> with PrefetchingIterator<> in method public asIterator(array int...) : Iterator<Integer> from class org.neo4j.internal.helpers.collection.Iterators


    public static <T> Iterator<T> iterator( final T item )
    {
        if ( item == null )
        {
            return emptyIterator();
        }

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

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

            @Override
            public T next()
            {
                if ( !hasNext() )
                {
                    throw new NoSuchElementException();
                }
                T toReturn = myItem;
                myItem = null;
                return toReturn;
            }

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

    public static <T> Iterator<T> iterator( final T item )
    {
        if ( item == null )
        {
            return emptyIterator();
        }

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

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

            @Override
            public T next()
            {
                if ( !hasNext() )
                {
                    throw new NoSuchElementException();
                }
                T toReturn = myItem;
                myItem = null;
                return toReturn;
            }

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

Replace Generic With Diamond Iterator<T> with Iterator<> in method public iterator(item T) : Iterator<T> from class org.neo4j.internal.helpers.collection.Iterators


    public static <T> Iterator<T> appendTo( Iterator<T> iterator, T... appended )
    {
        return new Iterator<>()
        {
            private int index;

            @Override
            public boolean hasNext()
            {
                return iterator.hasNext() || index < appended.length;
            }

            @Override
            public T next()
            {
                if ( iterator.hasNext() )
                {
                    return iterator.next();
                }
                else if ( index < appended.length )
                {
                    return appended[index++];
                }
                else
                {
                    throw new NoSuchElementException();
                }
            }
        };
    }

    public static <T> Iterator<T> appendTo( Iterator<T> iterator, T... appended )
    {
        return new Iterator<T>()
        {
            private int index;

            @Override
            public boolean hasNext()
            {
                return iterator.hasNext() || index < appended.length;
            }

            @Override
            public T next()
            {
                if ( iterator.hasNext() )
                {
                    return iterator.next();
                }
                else if ( index < appended.length )
                {
                    return appended[index++];
                }
                else
                {
                    throw new NoSuchElementException();
                }
            }
        };
    }

Replace Generic With Diamond Iterator<T> with Iterator<> in method public appendTo(iterator Iterator<T>, appended T...) : Iterator<T> from class org.neo4j.internal.helpers.collection.Iterators


    public static <T> Iterator<T> prependTo( Iterator<T> iterator, T... prepended )
    {
        return new Iterator<>()
        {
            private int index;

            @Override
            public boolean hasNext()
            {
                return index < prepended.length || iterator.hasNext();
            }

            @Override
            public T next()
            {
                if ( index < prepended.length )
                {
                    return prepended[index++];
                }
                else if ( iterator.hasNext() )
                {
                    return iterator.next();
                }
                else
                {
                    throw new NoSuchElementException();
                }
            }
        };
    }

    public static <T> Iterator<T> prependTo( Iterator<T> iterator, T... prepended )
    {
        return new Iterator<T>()
        {
            private int index;

            @Override
            public boolean hasNext()
            {
                return index < prepended.length || iterator.hasNext();
            }

            @Override
            public T next()
            {
                if ( index < prepended.length )
                {
                    return prepended[index++];
                }
                else if ( iterator.hasNext() )
                {
                    return iterator.next();
                }
                else
                {
                    throw new NoSuchElementException();
                }
            }
        };
    }

Replace Generic With Diamond Iterator<T> with Iterator<> in method public prependTo(iterator Iterator<T>, prepended T...) : Iterator<T> from class org.neo4j.internal.helpers.collection.Iterators


    public static <T> ResourceIterator<T> resourceIterator( final Iterator<T> iterator, final Resource resource )
    {
        return new PrefetchingResourceIterator<>()
        {
            @Override
            public void close()
            {
                resource.close();
            }

            @Override
            protected T fetchNextOrNull()
            {
                return iterator.hasNext() ? iterator.next() : null;
            }
        };
    }

    public static <T> ResourceIterator<T> resourceIterator( final Iterator<T> iterator, final Resource resource )
    {
        return new PrefetchingResourceIterator<T>()
        {
            @Override
            public void close()
            {
                resource.close();
            }

            @Override
            protected T fetchNextOrNull()
            {
                return iterator.hasNext() ? iterator.next() : null;
            }
        };
    }

Replace Generic With Diamond PrefetchingResourceIterator<T> with PrefetchingResourceIterator<> in method public resourceIterator(iterator Iterator<T>, resource Resource) : ResourceIterator<T> from class org.neo4j.internal.helpers.collection.Iterators


    public static <T, EX extends Exception> RawIterator<T, EX> asRawIterator( Iterator<T> iter )
    {
        return new RawIterator<>()
        {
            @Override
            public boolean hasNext()
            {
                return iter.hasNext();
            }

            @Override
            public T next()
            {
                return iter.next();
            }
        };
    }

    public static <T, EX extends Exception> RawIterator<T, EX> asRawIterator( Iterator<T> iter )
    {
        return new RawIterator<T,EX>()
        {
            @Override
            public boolean hasNext()
            {
                return iter.hasNext();
            }

            @Override
            public T next()
            {
                return iter.next();
            }
        };
    }

Replace Generic With Diamond RawIterator<T,EX> with RawIterator<> in method public asRawIterator(iter Iterator<T>) : RawIterator<T,EX> from class org.neo4j.internal.helpers.collection.Iterators


    public static <T> PrefetchingIterator<T> prefetching( Iterator<T> iterator )
    {
        return iterator instanceof PrefetchingIterator ? (PrefetchingIterator<T>) iterator : new PrefetchingIterator<>()
        {
            @Override
            protected T fetchNextOrNull()
            {
                return iterator.hasNext() ? iterator.next() : null;
            }
        };
    }

    public static <T> PrefetchingIterator<T> prefetching( Iterator<T> iterator )
    {
        return iterator instanceof PrefetchingIterator ? (PrefetchingIterator<T>) iterator :
               new PrefetchingIterator<T>()
               {
                   @Override
                   protected T fetchNextOrNull()
                   {
                       return iterator.hasNext() ? iterator.next() : null;
                   }
               };
    }

Replace Generic With Diamond PrefetchingIterator<T> with PrefetchingIterator<> in method public prefetching(iterator Iterator<T>) : PrefetchingIterator<T> from class org.neo4j.internal.helpers.collection.Iterators


    @SafeVarargs
    private static <T> Iterator<T> asIterator( final int maxItems, final T... array )
    {
        return new PrefetchingIterator<>()
        {
            private int index;

            @Override
            protected T fetchNextOrNull()
            {
                try
                {
                    return index < array.length && index < maxItems ? array[index] : null;
                }
                finally
                {
                    index++;
                }
            }
        };
    }

    @SafeVarargs
    public static <T> Iterator<T> asIterator( final int maxItems, final T... array )
    {
        return new PrefetchingIterator<T>()
        {
            private int index;

            @Override
            protected T fetchNextOrNull()
            {
                try
                {
                    return index < array.length && index < maxItems ? array[index] : null;
                }
                finally
                {
                    index++;
                }
            }
        };
    }

Replace Generic With Diamond PrefetchingIterator<T> with PrefetchingIterator<> in method private asIterator(maxItems int, array T...) : Iterator<T> from class org.neo4j.internal.helpers.collection.Iterators


    public static <R> ResourceIterator<R> newResourceIterator( Iterator<R> iterator, Resource... resources )
    {
        return new ResourceClosingIterator<>( iterator, resources )
        {
            @Override
            public R map( R elem )
            {
                return elem;
            }
        };
    }

    public static <R> ResourceIterator<R> newResourceIterator( Iterator<R> iterator, Resource... resources )
    {
        return new ResourceClosingIterator<R,R>( iterator, resources )
        {
            @Override
            public R map( R elem )
            {
                return elem;
            }
        };
    }

Replace Generic With Diamond ResourceClosingIterator<R,R> with ResourceClosingIterator<> in method public newResourceIterator(iterator Iterator<R>, resources Resource...) : ResourceIterator<R> from class org.neo4j.internal.helpers.collection.ResourceClosingIterator


    private static Result result( String column, Object value )
    {
        Result result = Mockito.mock( Result.class );
        Mockito.when( result.columns() ).thenReturn( singletonList( column ) );
        final Iterator<Map<String, Object>> inner = singletonList( singletonMap( column, value ) ).iterator();

        final ResourceIterator<Map<String, Object>> iterator = new ResourceIterator<>()
        {
            @Override
            public void close()
            {
            }

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

            @Override
            public Map<String,Object> next()
            {
                return inner.next();
            }

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

        Mockito.when( result.hasNext() ).thenAnswer( invocation -> iterator.hasNext() );
        Mockito.when( result.next() ).thenAnswer( invocation -> iterator.next() );
        return result;
    }

    @SuppressWarnings( "unchecked" )
    private Result result( String column, Object value )
    {
        Result result = Mockito.mock( Result.class );
        Mockito.when( result.columns() ).thenReturn( asList( column ) );
        final Iterator<Map<String, Object>> inner = asList( singletonMap( column, value ) ).iterator();

        final ResourceIterator<Map<String, Object>> iterator = new ResourceIterator<Map<String, Object>>()
        {
            @Override
            public void close()
            {
            }

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

            @Override
            public Map<String, Object> next()
            {
                return inner.next();
            }

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

        Mockito.when( result.hasNext() ).thenAnswer( invocation -> iterator.hasNext() );
        Mockito.when( result.next() ).thenAnswer( invocation -> iterator.next() );
        return result;
    }

Replace Generic With Diamond ResourceIterator<Map<String,Object>> with ResourceIterator<> in method private result(column String, value Object) : Result from class org.neo4j.cypher.export.ExportTest


        private void prepareNextLevel()
        {
            Collection<Node> nodesToIterate = new ArrayList<>( this.nextNodes );
            this.nextNodes.clear();
            this.lastPath.setLength( currentDepth );
            closeRelationshipsIterator();
            this.nextRelationships = new NestingResourceIterator<>( nodesToIterate.iterator() )
            {
                @Override
                protected ResourceIterator<Relationship> createNestedIterator( Node node )
                {
                    lastPath.setEndNode( node );
                    return Iterators.asResourceIterator( expander.expand( lastPath, BranchState.NO_STATE ).iterator() );
                }
            };
            this.currentDepth++;
            this.sharedCurrentDepth.increment();
        }

        private void prepareNextLevel()
        {
            Collection<Node> nodesToIterate = new ArrayList<>( this.nextNodes );
            this.nextNodes.clear();
            this.lastPath.setLength( currentDepth );
            closeRelationshipsIterator();
            this.nextRelationships = new NestingResourceIterator<Relationship,Node>( nodesToIterate.iterator() )
            {
                @Override
                protected ResourceIterator<Relationship> createNestedIterator( Node node )
                {
                    lastPath.setEndNode( node );
                    return Iterators.asResourceIterator( expander.expand( lastPath, BranchState.NO_STATE ).iterator() );
                }
            };
            this.currentDepth++;
            this.sharedCurrentDepth.increment();
        }

Replace Generic With Diamond NestingResourceIterator<Relationship,Node> with NestingResourceIterator<> in method private prepareNextLevel() : void from class org.neo4j.graphalgo.impl.path.ShortestPath.DirectionData


    private static Iterable<LinkedList<Relationship>> getPaths( Node connectingNode, DirectionData data,
            boolean stopAsap )
    {
        LevelData levelData = data.visitedNodes.get( connectingNode );
        if ( levelData.depth == 0 )
        {
            Collection<LinkedList<Relationship>> result = new ArrayList<>();
            result.add( new LinkedList<>() );
            return result;
        }
        Collection<PathData> set = new ArrayList<>();
        GraphDatabaseService graphDb = data.startNode.getGraphDatabase();
        for ( long rel : levelData.relsToHere )
        {
            set.add( new PathData( connectingNode, new LinkedList<>( Arrays.asList( graphDb
                    .getRelationshipById( rel ) ) ) ) );
            if ( stopAsap )
            {
                break;
            }
        }
        for ( int i = 0; i < levelData.depth - 1; i++ )
        {
            // One level
            Collection<PathData> nextSet = new ArrayList<>();
            for ( PathData entry : set )
            {
                // One path...
                Node otherNode = entry.rels.getFirst().getOtherNode( entry.node );
                LevelData otherLevelData = data.visitedNodes.get( otherNode );
                int counter = 0;
                for ( long rel : otherLevelData.relsToHere )
                {
                    // ...may split into several paths
                    LinkedList<Relationship> rels = ++counter == otherLevelData.relsToHere.length ?
                    // This is a little optimization which reduces number of
                    // lists being copied
                            entry.rels
                            : new LinkedList<>( entry.rels );
                    rels.addFirst( graphDb.getRelationshipById( rel ) );
                    nextSet.add( new PathData( otherNode, rels ) );
                    if ( stopAsap )
                    {
                        break;
                    }
                }
            }
            set = nextSet;
        }
        return new IterableWrapper<>( set )
        {
            @Override
            protected LinkedList<Relationship> underlyingObjectToObject( PathData object )
            {
                return object.rels;
            }
        };
    }

    private static Iterable<LinkedList<Relationship>> getPaths( Node connectingNode, DirectionData data,
            boolean stopAsap )
    {
        LevelData levelData = data.visitedNodes.get( connectingNode );
        if ( levelData.depth == 0 )
        {
            Collection<LinkedList<Relationship>> result = new ArrayList<>();
            result.add( new LinkedList<>() );
            return result;
        }
        Collection<PathData> set = new ArrayList<>();
        GraphDatabaseService graphDb = data.startNode.getGraphDatabase();
        for ( long rel : levelData.relsToHere )
        {
            set.add( new PathData( connectingNode, new LinkedList<>( Arrays.asList( graphDb
                    .getRelationshipById( rel ) ) ) ) );
            if ( stopAsap )
            {
                break;
            }
        }
        for ( int i = 0; i < levelData.depth - 1; i++ )
        {
            // One level
            Collection<PathData> nextSet = new ArrayList<>();
            for ( PathData entry : set )
            {
                // One path...
                Node otherNode = entry.rels.getFirst().getOtherNode( entry.node );
                LevelData otherLevelData = data.visitedNodes.get( otherNode );
                int counter = 0;
                for ( long rel : otherLevelData.relsToHere )
                {
                    // ...may split into several paths
                    LinkedList<Relationship> rels = ++counter == otherLevelData.relsToHere.length ?
                    // This is a little optimization which reduces number of
                    // lists being copied
                            entry.rels
                            : new LinkedList<>( entry.rels );
                    rels.addFirst( graphDb.getRelationshipById( rel ) );
                    nextSet.add( new PathData( otherNode, rels ) );
                    if ( stopAsap )
                    {
                        break;
                    }
                }
            }
            set = nextSet;
        }
        return new IterableWrapper<LinkedList<Relationship>,PathData>( set )
        {
            @Override
            protected LinkedList<Relationship> underlyingObjectToObject( PathData object )
            {
                return object.rels;
            }
        };
    }

Replace Generic With Diamond IterableWrapper<LinkedList<Relationship>,PathData> with IterableWrapper<> in method private getPaths(connectingNode Node, data DirectionData, stopAsap boolean) : Iterable<LinkedList<Relationship>> from class org.neo4j.graphalgo.impl.path.ShortestPath