I am working on migrating a Java project to Scala and encountered the below code:
private void searchClauses( TCustomSqlStatement select ) {
if ( !searchInClauses.contains( select ) ) {
searchInClauses.add( select );
}
else {
return;
}
if ( select instanceof TSelectSqlStatement ) {
TSelectSqlStatement statement = (TSelectSqlStatement) select;
HashMap clauseTable = new HashMap( );
if ( statement.getWhereClause( ) != null ) {
clauseTable.put( ( statement.getWhereClause( ).getCondition( ) ),
ClauseType.where );
}
for ( TExpression expr : (TExpression[]) clauseTable.keySet( ).toArray( new TExpression[0] ) ) {
ClauseType type = (ClauseType) clauseTable.get( expr );
searchExpression( expr,
select,
type == null ? null : type.name( ) );
searchTables( select );
}
}
}
In the else block of the IF condition, the previous developer wrote just return
and it is not even returning anything. If it is not returning null
, what is the use of having just return
?
Since I couldn't understand that particular line, I don't understand how to convert that particular IF condition in Scala.
Could anyone let me know how can I write the same block in Scala in a way that it doesn't impact the code below the first IF-ELSE condition ?