Skip to content

Commit

Permalink
Fix review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Lojjs committed Jan 18, 2018
1 parent 14de805 commit cfd6135
Showing 1 changed file with 27 additions and 30 deletions.
Expand Up @@ -35,6 +35,7 @@
import java.util.stream.DoubleStream;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
import java.util.stream.Stream;

import org.neo4j.cypher.internal.compiler.v3_2.spi.NodeIdWrapper;
import org.neo4j.cypher.internal.compiler.v3_2.spi.RelationshipIdWrapper;
Expand Down Expand Up @@ -424,19 +425,39 @@ else if ( iterable instanceof IntStream )
{
return ((IntStream) iterable).iterator();
}
else if ( iterable == null )
{
return Collections.emptyIterator();
}
else if ( iterable instanceof String )
{
String[] singleStringArray = {(String) iterable};
return getIterator( singleStringArray, 1 );
return (Stream.of((String) iterable)).iterator();
}
else if ( iterable == null )
{
return Collections.emptyIterator();
}
else if ( iterable.getClass().isArray() )
{
int len = Array.getLength( iterable );
return getIterator( iterable, len );

return new Iterator()
{
private int position = 0;

@Override
public boolean hasNext()
{
return position < len;
}

@Override
public Object next()
{
if ( position >= len )
{
throw new NoSuchElementException();
}
return Array.get( iterable, position++ );
}
};
}
else
{
Expand All @@ -445,30 +466,6 @@ else if ( iterable.getClass().isArray() )
}
}

private static Iterator getIterator( Object iterable, int len )
{
return new Iterator()
{
private int position = 0;

@Override
public boolean hasNext()
{
return position < len;
}

@Override
public Object next()
{
if ( position >= len )
{
throw new NoSuchElementException();
}
return Array.get( iterable, position++ );
}
};
}

@SuppressWarnings( "unchecked" )
public static LongStream toLongStream( Object list )
{
Expand Down

0 comments on commit cfd6135

Please sign in to comment.