Skip to content

Commit

Permalink
Clean ups, as found by Intellij
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvest committed May 30, 2017
1 parent 0d953c7 commit 2623155
Show file tree
Hide file tree
Showing 304 changed files with 772 additions and 1,431 deletions.
Expand Up @@ -172,12 +172,7 @@ public boolean equals( Object o )
{ {
return false; return false;
} }
if ( type != null ? !type.equals( that.type ) : that.type != null ) return type != null ? type.equals( that.type ) : that.type == null;
{
return false;
}

return true;
} }


@Override @Override
Expand Down
Expand Up @@ -49,12 +49,7 @@ public boolean equals( Object o )
} }


Record that = (Record) o; Record that = (Record) o;
if ( !Arrays.equals( fields, that.fields() ) ) return Arrays.equals( fields, that.fields() );
{
return false;
}

return true;
} }


@Override @Override
Expand Down
Expand Up @@ -67,12 +67,7 @@ public boolean equals( Object o )
{ {
return false; return false;
} }
if ( status != null ? !status.equals( that.status ) : that.status != null ) return status != null ? status.equals( that.status ) : that.status == null;
{
return false;
}

return true;
} }


@Override @Override
Expand Down
Expand Up @@ -169,7 +169,7 @@ public void shouldIncludeNotificationsIfPresent() throws Throwable
when( result.getQueryStatistics() ).thenReturn( queryStatistics ); when( result.getQueryStatistics() ).thenReturn( queryStatistics );
when( result.getQueryExecutionType() ).thenReturn( query( READ_WRITE ) ); when( result.getQueryExecutionType() ).thenReturn( query( READ_WRITE ) );


when( result.getNotifications() ).thenReturn( Arrays.<Notification>asList( when( result.getNotifications() ).thenReturn( Arrays.asList(
NotificationCode.INDEX_HINT_UNFULFILLABLE.notification( InputPosition.empty ), NotificationCode.INDEX_HINT_UNFULFILLABLE.notification( InputPosition.empty ),
NotificationCode.PLANNER_UNSUPPORTED.notification( new InputPosition( 4, 5, 6 ) ) NotificationCode.PLANNER_UNSUPPORTED.notification( new InputPosition( 4, 5, 6 ) )
) ); ) );
Expand Down
Expand Up @@ -423,7 +423,7 @@ public void onFinish()
// Then // Then
assertTrue( pullAllCallbackCalled.await( 30, TimeUnit.SECONDS ) ); assertTrue( pullAllCallbackCalled.await( 30, TimeUnit.SECONDS ) );
final Neo4jError err = error.get(); final Neo4jError err = error.get();
assertThat( err.status(), equalTo( (Status) Status.General.UnknownError ) ); assertThat( err.status(), equalTo( Status.General.UnknownError ) );
assertThat( err.message(), CoreMatchers.containsString( "Ooopsies!" ) ); assertThat( err.message(), CoreMatchers.containsString( "Ooopsies!" ) );
} }


Expand All @@ -448,7 +448,7 @@ public void shouldBeAbleToCleanlyRunMultipleSessionsInSingleThread() throws Thro


// Then the two should not have interfered with each other // Then the two should not have interfered with each other
stream = runAndPull( secondMachine, "MATCH (a:Person) WHERE id(a) = " + id + " RETURN COUNT(*)" ); stream = runAndPull( secondMachine, "MATCH (a:Person) WHERE id(a) = " + id + " RETURN COUNT(*)" );
assertThat( ((Record) stream[0]).fields()[0], equalTo( (Object) 1L ) ); assertThat( ((Record) stream[0]).fields()[0], equalTo( 1L ) );
} }


@Test @Test
Expand Down Expand Up @@ -545,7 +545,7 @@ public void shouldAllowNewTransactionAfterFailure() throws Throwable
Object[] stream = runAndPull( machine, "RETURN 1" ); Object[] stream = runAndPull( machine, "RETURN 1" );


// Then // Then
assertThat( ((Record) stream[0]).fields()[0], equalTo( (Object) 1L ) ); assertThat( ((Record) stream[0]).fields()[0], equalTo( 1L ) );
} }


private String createLocalIrisData( BoltStateMachine machine ) throws Exception private String createLocalIrisData( BoltStateMachine machine ) throws Exception
Expand Down
Expand Up @@ -25,7 +25,7 @@


public interface TransportConnection public interface TransportConnection
{ {
TransportConnection connect( HostnamePort address ) throws IOException, Exception; TransportConnection connect( HostnamePort address ) throws Exception;


TransportConnection send( byte[] rawBytes ) throws IOException; TransportConnection send( byte[] rawBytes ) throws IOException;


Expand Down
Expand Up @@ -64,7 +64,7 @@ public CachingIterator( Iterator<T> source )
@Override @Override
public boolean hasNext() public boolean hasNext()
{ {
return visited.size() > position ? true : source.hasNext(); return visited.size() > position || source.hasNext();
} }


/** /**
Expand Down
Expand Up @@ -45,7 +45,7 @@ public CombiningIterator( Iterator<? extends Iterator<T>> iterators )


public CombiningIterator( T first, Iterator<T> rest ) public CombiningIterator( T first, Iterator<T> rest )
{ {
this( Collections.<Iterator<T>>emptyList() ); this( Collections.emptyList() );
this.hasFetchedNext = true; this.hasFetchedNext = true;
this.nextObject = first; this.nextObject = first;
this.currentIterator = rest; this.currentIterator = rest;
Expand Down
Expand Up @@ -101,7 +101,7 @@ protected void rethrow( Throwable t )
{ {
// TODO it's pretty bad that we have to do this. We should refactor our exception hierarchy // TODO it's pretty bad that we have to do this. We should refactor our exception hierarchy
// to eliminate the need for this hack. // to eliminate the need for this hack.
ExceptionHandlingIterable.<RuntimeException>sneakyThrow( t ); ExceptionHandlingIterable.sneakyThrow( t );
} }


protected boolean exceptionOnHasNext( Throwable t ) protected boolean exceptionOnHasNext( Throwable t )
Expand Down
Expand Up @@ -48,11 +48,11 @@ public Iterator<T> iterator()


public static <T> Iterable<T> notNull( Iterable<T> source ) public static <T> Iterable<T> notNull( Iterable<T> source )
{ {
return new FilteringIterable<T>( source, Predicates.<T>notNull() ); return new FilteringIterable<T>( 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.<T>noDuplicates() ); return new FilteringIterable<T>( source, Predicates.noDuplicates() );
} }
} }
Expand Up @@ -57,11 +57,11 @@ protected T fetchNextOrNull()


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


public static <T> Iterator<T> noDuplicates( Iterator<T> source ) public static <T> Iterator<T> noDuplicates( Iterator<T> source )
{ {
return new FilteringIterator<>( source, Predicates.<T>noDuplicates() ); return new FilteringIterator<>( source, Predicates.noDuplicates() );
} }
} }
Expand Up @@ -143,6 +143,7 @@ public static Map<String, String> load( Reader reader ) throws IOException
{ {
Properties props = new Properties(); Properties props = new Properties();
props.load( reader ); props.load( reader );
//noinspection unchecked
return new HashMap<>( (Map) props ); return new HashMap<>( (Map) props );
} }


Expand Down
Expand Up @@ -197,7 +197,7 @@ public static boolean contains( final Throwable cause, final String containsMess


public static boolean contains( Throwable cause, Class... anyOfTheseClasses ) public static boolean contains( Throwable cause, Class... anyOfTheseClasses )
{ {
return contains( cause, org.neo4j.function.Predicates.<Throwable>instanceOfAny( anyOfTheseClasses ) ); return contains( cause, org.neo4j.function.Predicates.instanceOfAny( anyOfTheseClasses ) );
} }


public static boolean contains( Throwable cause, Predicate<Throwable> toLookFor ) public static boolean contains( Throwable cause, Predicate<Throwable> toLookFor )
Expand Down
Expand Up @@ -31,5 +31,5 @@ public enum LifecycleStatus
STOPPING, STOPPING,
STOPPED, STOPPED,
SHUTTING_DOWN, SHUTTING_DOWN,
SHUTDOWN; SHUTDOWN
} }
Expand Up @@ -105,7 +105,7 @@ public Function<NodeRecord,Check<NodeRecord,ConsistencyReport.NodeConsistencyRep
return keys != null return keys != null
? new RealCheck<>( node, ConsistencyReport.NodeConsistencyReport.class, reporter, ? new RealCheck<>( node, ConsistencyReport.NodeConsistencyReport.class, reporter,
RecordType.NODE, keys ) RecordType.NODE, keys )
: MandatoryProperties.<NodeRecord,ConsistencyReport.NodeConsistencyReport>noCheck(); : MandatoryProperties.noCheck();
}; };
} }


Expand Down
Expand Up @@ -156,11 +156,7 @@ private boolean closeBy( long id1, long id2 )
{ {
return true; return true;
} }
if ( Math.abs( id2 - id1 ) < this.proximityValue ) return Math.abs( id2 - id1 ) < this.proximityValue;
{
return true;
}
return false;
} }


public void upWrite( long id ) public void upWrite( long id )
Expand Down
Expand Up @@ -47,7 +47,7 @@ enum Type
backLinks, backLinks,
nullLinks, nullLinks,
nodeSparse, nodeSparse,
nodeDense; nodeDense
} }


void incAndGet( Type type, int threadIndex ); void incAndGet( Type type, int threadIndex );
Expand Down
Expand Up @@ -530,7 +530,7 @@ protected void transactionData( GraphStoreFixture.TransactionDataBuilder tx,
{ {
NodeRecord node = new NodeRecord( 42, false, -1, -1 ); NodeRecord node = new NodeRecord( 42, false, -1, -1 );
node.setInUse( true ); node.setInUse( true );
node.setLabelField( inlinedLabelsLongRepresentation( label1, label2 ), Collections.<DynamicRecord>emptySet() ); node.setLabelField( inlinedLabelsLongRepresentation( label1, label2 ), Collections.emptySet() );
tx.create( node ); tx.create( node );
} }
} ); } );
Expand Down Expand Up @@ -622,7 +622,7 @@ protected void transactionData( GraphStoreFixture.TransactionDataBuilder tx,
NodeRecord node = new NodeRecord( next.node(), false, -1, next.property() ); NodeRecord node = new NodeRecord( next.node(), false, -1, next.property() );
node.setInUse( true ); node.setInUse( true );
node.setLabelField( inlinedLabelsLongRepresentation( draconian ), node.setLabelField( inlinedLabelsLongRepresentation( draconian ),
Collections.<DynamicRecord>emptySet() ); Collections.emptySet() );
PropertyRecord property = new PropertyRecord( node.getNextProp(), node ); PropertyRecord property = new PropertyRecord( node.getNextProp(), node );
property.setInUse( true ); property.setInUse( true );
PropertyBlock block = new PropertyBlock(); PropertyBlock block = new PropertyBlock();
Expand Down
Expand Up @@ -150,7 +150,7 @@ public long maxMemoryUsage()
@Parameterized.Parameters( name = "{0},{1},{3}" ) @Parameterized.Parameters( name = "{0},{1},{3}" )
public static Collection<Object[]> data() public static Collection<Object[]> data()
{ {
return Arrays.<Object[]>asList( return Arrays.asList(


// synchronous I/O, actual node id input // synchronous I/O, actual node id input
new Object[]{new LongInputIdGenerator(), longs( AUTO ), fromInput(), true}, new Object[]{new LongInputIdGenerator(), longs( AUTO ), fromInput(), true},
Expand Down
Expand Up @@ -286,7 +286,7 @@ public static CharReadable files( Charset charset, File... files ) throws IOExce


public static CharReadable sources( Reader... sources ) throws IOException public static CharReadable sources( Reader... sources ) throws IOException
{ {
return new MultiReadable( iterator( sources, IOFunctions.<Reader>identity() ) ); return new MultiReadable( iterator( sources, IOFunctions.identity() ) );
} }


public static CharReadable sources( RawIterator<Reader,IOException> sources ) throws IOException public static CharReadable sources( RawIterator<Reader,IOException> sources ) throws IOException
Expand Down
Expand Up @@ -32,7 +32,7 @@ public interface Source extends Closeable
/** /**
* One chunk of data to read. * One chunk of data to read.
*/ */
public interface Chunk interface Chunk
{ {
/** /**
* @return character data to read * @return character data to read
Expand Down
Expand Up @@ -164,7 +164,7 @@ public String query()
@Override @Override
public List<PhaseEvent> phases() public List<PhaseEvent> phases()
{ {
return Collections.<PhaseEvent>unmodifiableList( phases ); return Collections.unmodifiableList( phases );
} }
} }


Expand Down
Expand Up @@ -210,7 +210,7 @@ public void shouldBeAbleToUseResultsOfPointProcedureAsInputToDistanceFunction()
{ {
// given procedure that produces a point // given procedure that produces a point
Procedures procedures = Procedures procedures =
((GraphDatabaseAPI) graphDb).getDependencyResolver().resolveDependency( Procedures.class ); graphDb.getDependencyResolver().resolveDependency( Procedures.class );
procedures.registerProcedure( PointProcs.class ); procedures.registerProcedure( PointProcs.class );


// when calling procedure that produces a point // when calling procedure that produces a point
Expand All @@ -229,7 +229,7 @@ public void shouldBeAbleToUseResultsOfPointGeometryProcedureAsInputToDistanceFun
{ {
// given procedure that produces a point // given procedure that produces a point
Procedures procedures = Procedures procedures =
((GraphDatabaseAPI) graphDb).getDependencyResolver().resolveDependency( Procedures.class ); graphDb.getDependencyResolver().resolveDependency( Procedures.class );
procedures.registerProcedure( PointProcs.class ); procedures.registerProcedure( PointProcs.class );


// when calling procedure that produces a point // when calling procedure that produces a point
Expand Down Expand Up @@ -258,7 +258,7 @@ public String getGeometryType()
@Override @Override
public List<Coordinate> getCoordinates() public List<Coordinate> getCoordinates()
{ {
return Arrays.asList( new Coordinate[]{coord} ); return Arrays.asList( coord );
} }


@Override @Override
Expand All @@ -284,7 +284,7 @@ public String getGeometryType()
@Override @Override
public List<Coordinate> getCoordinates() public List<Coordinate> getCoordinates()
{ {
return Arrays.asList( new Coordinate[]{coord} ); return Arrays.asList( coord );
} }


@Override @Override
Expand Down
Expand Up @@ -143,7 +143,7 @@ private void createData( long startingUserId, int numUsers, int numConnections )
{ {
for ( long userId = startingUserId; userId < numUsers + startingUserId; userId++ ) for ( long userId = startingUserId; userId < numUsers + startingUserId; userId++ )
{ {
db.execute( "CREATE (newUser:User {userId: {userId}})", singletonMap( "userId", (Object) userId ) ); db.execute( "CREATE (newUser:User {userId: {userId}})", singletonMap( "userId", userId ) );
} }
Map<String,Object> params = new HashMap<>(); Map<String,Object> params = new HashMap<>();
for ( int i = 0; i < numConnections; i++ ) for ( int i = 0; i < numConnections; i++ )
Expand All @@ -164,7 +164,7 @@ private void createData( long startingUserId, int numUsers, int numConnections )


private void executeDistantFriendsCountQuery( int userId ) private void executeDistantFriendsCountQuery( int userId )
{ {
Map<String,Object> params = singletonMap( "userId", (Object) (long) randomInt( userId ) ); Map<String,Object> params = singletonMap( "userId", (long) randomInt( userId ) );


try ( Result result = db.execute( try ( Result result = db.execute(
"MATCH (user:User { userId: {userId} } ) -[:FRIEND]- () -[:FRIEND]- (distantFriend) " + "MATCH (user:User { userId: {userId} } ) -[:FRIEND]- () -[:FRIEND]- (distantFriend) " +
Expand Down
Expand Up @@ -154,7 +154,7 @@ private class AStarIterator extends PrefetchingIterator<Node> implements Path
private final Node end; private final Node end;
private Node lastNode; private Node lastNode;
private final PriorityMap<Node, Node, Double> nextPrioritizedNodes = private final PriorityMap<Node, Node, Double> nextPrioritizedNodes =
PriorityMap.<Node, Double>withSelfKeyNaturalOrder(); PriorityMap.withSelfKeyNaturalOrder();
private final Map<Long, Visit> visitData = new HashMap<Long, Visit>(); private final Map<Long, Visit> visitData = new HashMap<Long, Visit>();


AStarIterator( Node start, Node end ) AStarIterator( Node start, Node end )
Expand Down
Expand Up @@ -84,12 +84,8 @@ protected boolean limitReached()
{ {
return true; return true;
} }
if ( maxNodesToTraverse >= 0 return maxNodesToTraverse >= 0
&& numberOfNodesTraversed >= maxNodesToTraverse ) && numberOfNodesTraversed >= maxNodesToTraverse;
{
return true;
}
return false;
} }


protected boolean limitReached( CostType cost1, CostType cost2 ) protected boolean limitReached( CostType cost1, CostType cost2 )
Expand Down
Expand Up @@ -90,11 +90,7 @@ protected boolean includePath( Path path, TraversalBranch startBranch, Traversal
{ {
shortestSoFar.setValue( cost ); shortestSoFar.setValue( cost );
} }
if ( NoneStrictMath.compare( cost, shortestSoFar.doubleValue(), epsilon ) <= 0 ) return NoneStrictMath.compare( cost, shortestSoFar.doubleValue(), epsilon ) <= 0;
{
return true;
}


return false;
} }
} }
Expand Up @@ -93,7 +93,7 @@ public int compare( P o1, P o2 )
public static <E, K, P extends Comparable<P>> PriorityMap<E, K, P> withNaturalOrder( public static <E, K, P extends Comparable<P>> PriorityMap<E, K, P> withNaturalOrder(
Converter<K, E> key ) Converter<K, E> key )
{ {
return PriorityMap.<E, K, P>withNaturalOrder( key, false ); return PriorityMap.withNaturalOrder( key, false );
} }
public static <E, K, P extends Comparable<P>> PriorityMap<E, K, P> withNaturalOrder( public static <E, K, P extends Comparable<P>> PriorityMap<E, K, P> withNaturalOrder(
Converter<K, E> key, boolean reversed ) Converter<K, E> key, boolean reversed )
Expand All @@ -109,13 +109,13 @@ public static <E, K, P extends Comparable<P>> PriorityMap<E, K, P> withNaturalOr


public static <K, P extends Comparable<P>> PriorityMap<K, K, P> withSelfKeyNaturalOrder() public static <K, P extends Comparable<P>> PriorityMap<K, K, P> withSelfKeyNaturalOrder()
{ {
return PriorityMap.<K, P>withSelfKeyNaturalOrder( false ); return PriorityMap.withSelfKeyNaturalOrder( false );
} }


public static <K, P extends Comparable<P>> PriorityMap<K, K, P> withSelfKeyNaturalOrder( public static <K, P extends Comparable<P>> PriorityMap<K, K, P> withSelfKeyNaturalOrder(
boolean reversed ) boolean reversed )
{ {
return PriorityMap.<K, P>withSelfKeyNaturalOrder( reversed, true ); return PriorityMap.withSelfKeyNaturalOrder( reversed, true );
} }


@SuppressWarnings( "unchecked" ) @SuppressWarnings( "unchecked" )
Expand Down
Expand Up @@ -87,7 +87,7 @@ public void setCurrentRelType( RelationshipType currentRelType )


public Node makeNode( String id ) public Node makeNode( String id )
{ {
return makeNode( id, Collections.<String, Object>emptyMap() ); return makeNode( id, Collections.emptyMap() );
} }


public Node makeNode( String id, Object... keyValuePairs ) public Node makeNode( String id, Object... keyValuePairs )
Expand Down Expand Up @@ -144,7 +144,7 @@ public String getNodeId( Node node )


public Relationship makeEdge( String node1, String node2 ) public Relationship makeEdge( String node1, String node2 )
{ {
return makeEdge( node1, node2, Collections.<String, Object>emptyMap() ); return makeEdge( node1, node2, Collections.emptyMap() );
} }


public Relationship makeEdge( String node1, String node2, Map<String, Object> edgeProperties ) public Relationship makeEdge( String node1, String node2, Map<String, Object> edgeProperties )
Expand Down

0 comments on commit 2623155

Please sign in to comment.