Skip to content

Commit

Permalink
Semi-automatic code cleanup
Browse files Browse the repository at this point in the history
*Explicit <>
*Collapse identical catch blocks
*Prefer try-with-resource
*Prefer lambdas and method references
*Collections.sort to List.sort
*Unnecessary casts
  • Loading branch information
klaren committed Feb 1, 2018
1 parent 336c7bf commit 74916dc
Show file tree
Hide file tree
Showing 357 changed files with 1,420 additions and 2,465 deletions.
1 change: 1 addition & 0 deletions build/checkstyle.xml
Expand Up @@ -67,6 +67,7 @@
<module name="UnnecessaryParentheses"/> <module name="UnnecessaryParentheses"/>
<module name="LeftCurly"> <module name="LeftCurly">
<property name="option" value="nl"/> <property name="option" value="nl"/>
<property name="tokens" value="INTERFACE_DEF, CLASS_DEF, ANNOTATION_DEF, ENUM_DEF, CTOR_DEF, METHOD_DEF, ENUM_CONSTANT_DEF, LITERAL_WHILE, LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_SYNCHRONIZED, LITERAL_SWITCH, LITERAL_DO, LITERAL_IF, LITERAL_ELSE, LITERAL_FOR, STATIC_INIT, OBJBLOCK"/>
</module> </module>
<module name="RightCurly"> <module name="RightCurly">
<property name="option" value="alone"/> <property name="option" value="alone"/>
Expand Down
Expand Up @@ -50,7 +50,7 @@ public class TransportWriteThrottle implements TransportThrottle


public TransportWriteThrottle( int lowWaterMark, int highWaterMark, Clock clock, Duration maxLockDuration ) public TransportWriteThrottle( int lowWaterMark, int highWaterMark, Clock clock, Duration maxLockDuration )
{ {
this( lowWaterMark, highWaterMark, clock, maxLockDuration, () -> new DefaultThrottleLock() ); this( lowWaterMark, highWaterMark, clock, maxLockDuration, DefaultThrottleLock::new );
} }


public TransportWriteThrottle( int lowWaterMark, int highWaterMark, Clock clock, Duration maxLockDuration, Supplier<ThrottleLock> lockSupplier ) public TransportWriteThrottle( int lowWaterMark, int highWaterMark, Clock clock, Duration maxLockDuration, Supplier<ThrottleLock> lockSupplier )
Expand Down
Expand Up @@ -258,10 +258,7 @@ private BoltResultHandle execute( MutableTransactionState ctx, SPI spi,
String statement, MapValue params ) String statement, MapValue params )
throws TransactionFailureException, QueryExecutionKernelException throws TransactionFailureException, QueryExecutionKernelException
{ {
return executeQuery( ctx, spi, statement, params, () -> return executeQuery( ctx, spi, statement, params, () -> closeTransaction( ctx, false ) );
{
closeTransaction( ctx, false );
} );
} }


@Override @Override
Expand Down
Expand Up @@ -202,24 +202,19 @@ public void shouldReadYourOwnWrites() throws Exception
BinaryLatch latch = new BinaryLatch(); BinaryLatch latch = new BinaryLatch();


long dbVersion = env.lastClosedTxId(); long dbVersion = env.lastClosedTxId();
Thread thread = new Thread() Thread thread = new Thread( () -> {
{ try ( BoltStateMachine machine = env.newMachine( boltChannel ) )
@Override
public void run()
{ {
try ( BoltStateMachine machine = env.newMachine( boltChannel ) ) machine.init( USER_AGENT, emptyMap(), null );
{ latch.await();
machine.init( USER_AGENT, emptyMap(), null ); machine.run( "MATCH (n:A) SET n.prop = 'two'", EMPTY_MAP, nullResponseHandler() );
latch.await(); machine.pullAll( nullResponseHandler() );
machine.run( "MATCH (n:A) SET n.prop = 'two'", EMPTY_MAP, nullResponseHandler() ); }
machine.pullAll( nullResponseHandler() ); catch ( BoltConnectionFatality connectionFatality )
} {
catch ( BoltConnectionFatality connectionFatality ) throw new RuntimeException( connectionFatality );
{
throw new RuntimeException( connectionFatality );
}
} }
}; } );
thread.start(); thread.start();


long dbVersionAfterWrite = dbVersion + 1; long dbVersionAfterWrite = dbVersion + 1;
Expand Down Expand Up @@ -266,37 +261,32 @@ public void shouldTerminateQueriesEvenIfUsingPeriodicCommit() throws Exception


final BoltStateMachine[] machine = {null}; final BoltStateMachine[] machine = {null};


Thread thread = new Thread() Thread thread = new Thread( () -> {
{ try ( BoltStateMachine stateMachine = env.newMachine( mock( BoltChannel.class ) ) )
@Override
public void run()
{ {
try ( BoltStateMachine stateMachine = env.newMachine( mock( BoltChannel.class ) ) ) machine[0] = stateMachine;
stateMachine.init( USER_AGENT, emptyMap(), null );
String query = format( "USING PERIODIC COMMIT 10 LOAD CSV FROM 'http://localhost:%d' AS line " +
"CREATE (n:A {id: line[0], square: line[1]}) " +
"WITH count(*) as number " +
"CREATE (n:ShouldNotExist)",
localPort );
try
{ {
machine[0] = stateMachine; latch.start();
stateMachine.init( USER_AGENT, emptyMap(), null ); stateMachine.run( query, EMPTY_MAP, nullResponseHandler() );
String query = format( "USING PERIODIC COMMIT 10 LOAD CSV FROM 'http://localhost:%d' AS line " + stateMachine.pullAll( nullResponseHandler() );
"CREATE (n:A {id: line[0], square: line[1]}) " +
"WITH count(*) as number " +
"CREATE (n:ShouldNotExist)",
localPort );
try
{
latch.start();
stateMachine.run( query, EMPTY_MAP, nullResponseHandler() );
stateMachine.pullAll( nullResponseHandler() );
}
finally
{
latch.finish();
}
} }
catch ( BoltConnectionFatality connectionFatality ) finally
{ {
throw new RuntimeException( connectionFatality ); latch.finish();
} }
} }
}; catch ( BoltConnectionFatality connectionFatality )
{
throw new RuntimeException( connectionFatality );
}
} );
thread.setName( "query runner" ); thread.setName( "query runner" );
thread.start(); thread.start();


Expand Down
Expand Up @@ -28,7 +28,6 @@
import java.util.Collection; import java.util.Collection;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
Expand Down Expand Up @@ -159,20 +158,20 @@ private void createAndRollback( TransportConnection client ) throws Exception
{ {
client.send( createAndRollback ); client.send( createAndRollback );
assertThat( client, eventuallyReceives( assertThat( client, eventuallyReceives(
msgSuccess( CoreMatchers.<Map<? extends String,?>>allOf( hasEntry( is( "fields" ), equalTo( emptyList() ) ), msgSuccess( CoreMatchers.allOf( hasEntry( is( "fields" ), equalTo( emptyList() ) ),
hasKey( "result_available_after" ) ) ), hasKey( "result_available_after" ) ) ),
msgSuccess(), msgSuccess(),
msgSuccess( CoreMatchers.<Map<? extends String,?>>allOf( hasEntry( is( "fields" ), equalTo( emptyList() ) ), msgSuccess( CoreMatchers.allOf( hasEntry( is( "fields" ), equalTo( emptyList() ) ),
hasKey( "result_available_after" ) ) ), hasKey( "result_available_after" ) ) ),
msgSuccess(), msgSuccess(),
msgSuccess( CoreMatchers.<Map<? extends String,?>>allOf( hasEntry( is( "fields" ), equalTo( emptyList() ) ), msgSuccess( CoreMatchers.allOf( hasEntry( is( "fields" ), equalTo( emptyList() ) ),
hasKey( "result_available_after" ) ) ), hasKey( "result_available_after" ) ) ),
msgSuccess() ) ); msgSuccess() ) );


// Verify no visible data // Verify no visible data
client.send( matchAll ); client.send( matchAll );
assertThat( client, eventuallyReceives( assertThat( client, eventuallyReceives(
msgSuccess(CoreMatchers.<Map<? extends String,?>>allOf( hasEntry( is( "fields" ), equalTo( singletonList( "n" ) ) ), msgSuccess(CoreMatchers.allOf( hasEntry( is( "fields" ), equalTo( singletonList( "n" ) ) ),
hasKey( "result_available_after" ) ) ), hasKey( "result_available_after" ) ) ),
msgSuccess() ) ); msgSuccess() ) );


Expand Down
Expand Up @@ -30,7 +30,6 @@


import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;


import org.neo4j.bolt.v1.transport.socket.client.SecureSocketConnection; import org.neo4j.bolt.v1.transport.socket.client.SecureSocketConnection;
import org.neo4j.bolt.v1.transport.socket.client.SecureWebSocketConnection; import org.neo4j.bolt.v1.transport.socket.client.SecureWebSocketConnection;
Expand Down Expand Up @@ -144,12 +143,12 @@ public void shouldRunSimpleStatement() throws Throwable
assertThat( client, eventuallyReceives( new byte[]{0, 0, 0, 1} ) ); assertThat( client, eventuallyReceives( new byte[]{0, 0, 0, 1} ) );
assertThat( client, eventuallyReceives( assertThat( client, eventuallyReceives(
msgSuccess(), msgSuccess(),
msgSuccess( CoreMatchers.<Map<? extends String,?>>allOf( hasEntry( is( "fields" ), msgSuccess( CoreMatchers.allOf( hasEntry( is( "fields" ),
equalTo( asList( "a", "a_squared" ) ) ), hasKey( "result_available_after" ) ) ), equalTo( asList( "a", "a_squared" ) ) ), hasKey( "result_available_after" ) ) ),
msgRecord( eqRecord( equalTo( longValue( 1L ) ), equalTo( longValue( 1L ) ) ) ), msgRecord( eqRecord( equalTo( longValue( 1L ) ), equalTo( longValue( 1L ) ) ) ),
msgRecord( eqRecord( equalTo( longValue( 2L ) ), equalTo( longValue( 4L ) ) ) ), msgRecord( eqRecord( equalTo( longValue( 2L ) ), equalTo( longValue( 4L ) ) ) ),
msgRecord( eqRecord( equalTo( longValue( 3L ) ), equalTo( longValue( 9L ) ) ) ), msgRecord( eqRecord( equalTo( longValue( 3L ) ), equalTo( longValue( 9L ) ) ) ),
msgSuccess( CoreMatchers.<Map<? extends String,?>>allOf( hasEntry( is( "type" ), equalTo( "r" ) ), msgSuccess( CoreMatchers.allOf( hasEntry( is( "type" ), equalTo( "r" ) ),
hasKey( "result_consumed_after" ) ) ) ) ); hasKey( "result_consumed_after" ) ) ) ) );
} }


Expand All @@ -169,9 +168,9 @@ public void shouldRespondWithMetadataToDiscardAll() throws Throwable
assertThat( client, eventuallyReceives( assertThat( client, eventuallyReceives(
msgSuccess(), msgSuccess(),
msgSuccess( msgSuccess(
CoreMatchers.<Map<? extends String,?>>allOf( hasEntry( is( "fields" ), equalTo( asList( "a", "a_squared" ) ) ), CoreMatchers.allOf( hasEntry( is( "fields" ), equalTo( asList( "a", "a_squared" ) ) ),
hasKey( "result_available_after" ) ) ), hasKey( "result_available_after" ) ) ),
msgSuccess( CoreMatchers.<Map<? extends String,?>>allOf( hasEntry( is( "type" ), equalTo( "r" ) ), msgSuccess( CoreMatchers.allOf( hasEntry( is( "type" ), equalTo( "r" ) ),
hasKey( "result_consumed_after" ) ) ) ) ); hasKey( "result_consumed_after" ) ) ) ) );
} }


Expand Down Expand Up @@ -219,7 +218,7 @@ public void shouldRunProcedure() throws Throwable
assertThat( client, eventuallyReceives( new byte[]{0, 0, 0, 1} ) ); assertThat( client, eventuallyReceives( new byte[]{0, 0, 0, 1} ) );
assertThat( client, eventuallyReceives( assertThat( client, eventuallyReceives(
msgSuccess(), msgSuccess(),
msgSuccess( CoreMatchers.<Map<? extends String,?>>allOf( hasEntry( is( "fields" ), equalTo( singletonList( "age" ) ) ), msgSuccess( CoreMatchers.allOf( hasEntry( is( "fields" ), equalTo( singletonList( "age" ) ) ),
hasKey( "result_available_after" ) ) ), hasKey( "result_available_after" ) ) ),
msgRecord( eqRecord( equalTo( longValue( 2L ) ) ) ), msgRecord( eqRecord( equalTo( longValue( 2L ) ) ) ),
msgSuccess() ) ); msgSuccess() ) );
Expand All @@ -231,7 +230,7 @@ public void shouldRunProcedure() throws Throwable


// Then // Then
assertThat( client, eventuallyReceives( assertThat( client, eventuallyReceives(
msgSuccess( CoreMatchers.<Map<? extends String,?>>allOf( hasEntry( is( "fields" ), equalTo( singletonList( "label" ) ) ), msgSuccess( CoreMatchers.allOf( hasEntry( is( "fields" ), equalTo( singletonList( "label" ) ) ),
hasKey( "result_available_after" ) ) ), hasKey( "result_available_after" ) ) ),
msgRecord( eqRecord( Matchers.equalTo( stringValue( "Test" ) ) ) ), msgRecord( eqRecord( Matchers.equalTo( stringValue( "Test" ) ) ) ),
msgSuccess() msgSuccess()
Expand All @@ -253,7 +252,7 @@ public void shouldHandleDeletedNodes() throws Throwable
assertThat( client, eventuallyReceives( new byte[]{0, 0, 0, 1} ) ); assertThat( client, eventuallyReceives( new byte[]{0, 0, 0, 1} ) );
assertThat( client, eventuallyReceives( assertThat( client, eventuallyReceives(
msgSuccess(), msgSuccess(),
msgSuccess( CoreMatchers.<Map<? extends String,?>>allOf( hasEntry( is( "fields" ), equalTo( singletonList( "n" ) ) ), msgSuccess( CoreMatchers.allOf( hasEntry( is( "fields" ), equalTo( singletonList( "n" ) ) ),
hasKey( "result_available_after" ) ) ) ) ); hasKey( "result_available_after" ) ) ) ) );


// //
Expand Down Expand Up @@ -284,7 +283,7 @@ public void shouldHandleDeletedRelationships() throws Throwable
assertThat( client, eventuallyReceives( new byte[]{0, 0, 0, 1} ) ); assertThat( client, eventuallyReceives( new byte[]{0, 0, 0, 1} ) );
assertThat( client, eventuallyReceives( assertThat( client, eventuallyReceives(
msgSuccess(), msgSuccess(),
msgSuccess( CoreMatchers.<Map<? extends String,?>>allOf( hasEntry( is( "fields" ), equalTo( singletonList( "r" ) ) ), msgSuccess( CoreMatchers.allOf( hasEntry( is( "fields" ), equalTo( singletonList( "r" ) ) ),
hasKey( "result_available_after" ) ) ) ) ); hasKey( "result_available_after" ) ) ) ) );


// //
Expand Down Expand Up @@ -328,7 +327,7 @@ public void shouldNotLeakStatsToNextStatement() throws Throwable
assertThat( client, eventuallyReceives( assertThat( client, eventuallyReceives(
msgSuccess(), msgSuccess(),
msgRecord( eqRecord( equalTo( longValue( 1L ) ) ) ), msgRecord( eqRecord( equalTo( longValue( 1L ) ) ) ),
msgSuccess( CoreMatchers.<Map<? extends String,?>>allOf( hasEntry( is( "type" ), equalTo( "r" ) ), msgSuccess( CoreMatchers.allOf( hasEntry( is( "type" ), equalTo( "r" ) ),
hasKey( "result_consumed_after" ) ) ) ) ); hasKey( "result_consumed_after" ) ) ) ) );
} }


Expand Down Expand Up @@ -374,7 +373,7 @@ public void shouldFailNicelyOnPoints() throws Throwable
assertThat( client, eventuallyReceives( new byte[]{0, 0, 0, 1} ) ); assertThat( client, eventuallyReceives( new byte[]{0, 0, 0, 1} ) );
assertThat( client, eventuallyReceives( assertThat( client, eventuallyReceives(
msgSuccess(), msgSuccess(),
msgSuccess( CoreMatchers.<Map<? extends String,?>>allOf( hasEntry( is( "fields" ), equalTo( singletonList( "p" ) ) ), msgSuccess( CoreMatchers.allOf( hasEntry( is( "fields" ), equalTo( singletonList( "p" ) ) ),
hasKey( "result_available_after" ) ) ), hasKey( "result_available_after" ) ) ),
msgRecord( eqRecord( equalTo( NO_VALUE ) ) ), msgRecord( eqRecord( equalTo( NO_VALUE ) ) ),
msgFailure( Status.Request.Invalid, "Point is not yet supported as a return type in Bolt" ) ) ); msgFailure( Status.Request.Invalid, "Point is not yet supported as a return type in Bolt" ) ) );
Expand Down
Expand Up @@ -25,7 +25,6 @@
import org.objectweb.asm.tree.AbstractInsnNode; import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode; import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.TryCatchBlockNode;
import org.objectweb.asm.tree.analysis.Analyzer; import org.objectweb.asm.tree.analysis.Analyzer;
import org.objectweb.asm.tree.analysis.AnalyzerException; import org.objectweb.asm.tree.analysis.AnalyzerException;
import org.objectweb.asm.tree.analysis.BasicValue; import org.objectweb.asm.tree.analysis.BasicValue;
Expand Down Expand Up @@ -144,9 +143,9 @@ public void check( ClassLoader classpathLoader, Collection<ByteCodes> byteCodes
private static void verify( AssignmentChecker check, ClassNode clazz, List<Failure> failures ) private static void verify( AssignmentChecker check, ClassNode clazz, List<Failure> failures )
{ {
Verifier verifier = new Verifier( clazz, check ); Verifier verifier = new Verifier( clazz, check );
for ( MethodNode method : (Iterable<MethodNode>) clazz.methods ) for ( MethodNode method : clazz.methods )
{ {
Analyzer analyzer = new Analyzer( verifier ); Analyzer<?> analyzer = new Analyzer<>( verifier );
try try
{ {
analyzer.analyze( clazz.name, method ); analyzer.analyze( clazz.name, method );
Expand Down Expand Up @@ -263,7 +262,7 @@ private static String detailedMessage(
} }
for ( int j = 0; j < method.tryCatchBlocks.size(); j++ ) for ( int j = 0; j < method.tryCatchBlocks.size(); j++ )
{ {
((TryCatchBlockNode) method.tryCatchBlocks.get( j )).accept( mv ); method.tryCatchBlocks.get( j ).accept( mv );
out.print( " " + formatted.text.get( formatted.text.size() - 1 ) ); out.print( " " + formatted.text.get( formatted.text.size() - 1 ) );
} }
} }
Expand Down Expand Up @@ -362,7 +361,7 @@ private static Type superClass( ClassNode clazz )
private static List<Type> interfaces( ClassNode clazz ) private static List<Type> interfaces( ClassNode clazz )
{ {
List<Type> interfaces = new ArrayList<>( clazz.interfaces.size() ); List<Type> interfaces = new ArrayList<>( clazz.interfaces.size() );
for ( String iFace : (Iterable<String>) clazz.interfaces ) for ( String iFace : clazz.interfaces )
{ {
interfaces.add( Type.getObjectType( iFace ) ); interfaces.add( Type.getObjectType( iFace ) );
} }
Expand Down Expand Up @@ -438,7 +437,7 @@ private boolean isAssignableFrom( Type target, ClassNode value )
{ {
return true; return true;
} }
for ( String iFace : (Iterable<String>) value.interfaces ) for ( String iFace : value.interfaces )
{ {
if ( isAssignableFrom( target, Type.getObjectType( iFace ) ) ) if ( isAssignableFrom( target, Type.getObjectType( iFace ) ) )
{ {
Expand Down
Expand Up @@ -36,7 +36,7 @@
public class CachingIterator<T> implements ListIterator<T> public class CachingIterator<T> implements ListIterator<T>
{ {
private final Iterator<T> source; private final Iterator<T> source;
private final List<T> visited = new ArrayList<T>(); private final List<T> visited = new ArrayList<>();
private int position; private int position;
private T current; private T current;


Expand Down
Expand Up @@ -40,11 +40,11 @@ public CombiningIterable( Iterable<Iterable<T>> iterables )
@Override @Override
public Iterator<T> iterator() public Iterator<T> iterator()
{ {
LinkedList<Iterator<T>> iterators = new LinkedList<Iterator<T>>(); LinkedList<Iterator<T>> iterators = new LinkedList<>();
for ( Iterable<T> iterable : iterables ) for ( Iterable<T> iterable : iterables )
{ {
iterators.add( iterable.iterator() ); iterators.add( iterable.iterator() );
} }
return new CombiningIterator<T>( iterators ); return new CombiningIterator<>( iterators );
} }
} }
Expand Up @@ -44,16 +44,16 @@ public FilteringIterable( Iterable<T> source, Predicate<T> predicate )
@Override @Override
public Iterator<T> iterator() public Iterator<T> iterator()
{ {
return new FilteringIterator<T>( source.iterator(), predicate ); return new FilteringIterator<>( source.iterator(), predicate );
} }


public static <T> Iterable<T> notNull( Iterable<T> source ) public static <T> Iterable<T> notNull( Iterable<T> source )
{ {
return new FilteringIterable<T>( source, Predicates.notNull() ); return new FilteringIterable<>( source, Predicates.notNull() );
} }


public static <T> Iterable<T> noDuplicates( Iterable<T> source ) public static <T> Iterable<T> noDuplicates( Iterable<T> source )
{ {
return new FilteringIterable<T>( source, Predicates.noDuplicates() ); return new FilteringIterable<>( source, Predicates.noDuplicates() );
} }
} }
Expand Up @@ -660,12 +660,12 @@ public static <T> long count( Iterable<T> iterable, Predicate<T> filter )
*/ */
public static <T> Collection<T> asCollection( Iterable<T> iterable ) public static <T> Collection<T> asCollection( Iterable<T> iterable )
{ {
return addToCollection( iterable, new ArrayList<T>() ); return addToCollection( iterable, new ArrayList<>() );
} }


public static <T> List<T> asList( Iterable<T> iterator ) public static <T> List<T> asList( Iterable<T> iterator )
{ {
return addToCollection( iterator, new ArrayList<T>() ); return addToCollection( iterator, new ArrayList<>() );
} }


public static <T, U> Map<T, U> asMap( Iterable<Pair<T, U>> pairs ) public static <T, U> Map<T, U> asMap( Iterable<Pair<T, U>> pairs )
Expand All @@ -687,7 +687,7 @@ public static <T, U> Map<T, U> asMap( Iterable<Pair<T, U>> pairs )
*/ */
public static <T> Set<T> asSet( Iterable<T> iterable ) public static <T> Set<T> asSet( Iterable<T> iterable )
{ {
return addToCollection( iterable, new HashSet<T>() ); return addToCollection( iterable, new HashSet<>() );
} }


/** /**
Expand Down Expand Up @@ -897,11 +897,10 @@ public static <T> Iterable<T> option( final T item )
return () -> Iterators.iterator( item ); return () -> Iterators.iterator( item );
} }


@SuppressWarnings( "rawtypes" ) public static <T, S extends Comparable<? super S>> Iterable<T> sort( Iterable<T> iterable, final Function<T, S> compareFunction )
public static <T, S extends Comparable> Iterable<T> sort( Iterable<T> iterable, final Function<T, S> compareFunction )
{ {
List<T> list = asList( iterable ); List<T> list = asList( iterable );
Collections.sort( list, Comparator.comparing( compareFunction::apply ) ); list.sort( Comparator.comparing( compareFunction ) );
return list; return list;
} }


Expand Down
Expand Up @@ -389,12 +389,12 @@ public static <T> long count( Iterator<T> iterator, Predicate<T> filter )


public static <T> Collection<T> asCollection( Iterator<T> iterable ) public static <T> Collection<T> asCollection( Iterator<T> iterable )
{ {
return addToCollection( iterable, new ArrayList<T>() ); return addToCollection( iterable, new ArrayList<>() );
} }


public static <T> List<T> asList( Iterator<T> iterator ) public static <T> List<T> asList( Iterator<T> iterator )
{ {
return addToCollection( iterator, new ArrayList<T>() ); return addToCollection( iterator, new ArrayList<>() );
} }


public static <T, EX extends Exception> List<T> asList( RawIterator<T, EX> iterator ) throws EX public static <T, EX extends Exception> List<T> asList( RawIterator<T, EX> iterator ) throws EX
Expand All @@ -409,7 +409,7 @@ public static <T, EX extends Exception> List<T> asList( RawIterator<T, EX> itera


public static <T> Set<T> asSet( Iterator<T> iterator ) public static <T> Set<T> asSet( Iterator<T> iterator )
{ {
return addToCollection( iterator, new HashSet<T>() ); return addToCollection( iterator, new HashSet<>() );
} }


/** /**
Expand Down

0 comments on commit 74916dc

Please sign in to comment.