I find that it is not good practice to pass in a argument by its implemented name if it has a backing interface. ArrayList<T>
is a good example, it is based on the interface List<T>
and is just as capable as ArrayList. It is useful this way because if you decide to pass in an immutable List, or a different type of List you don't have to worry about fixing compiler errors down the road.
Having nested for loops and if statements makes it difficult to know where and what to do. I find it often easier to take the contents inside a for loop and put them in a extracted method giving it a good name.
This little bit of code is hard to read. plus comparing a boolean is not good practice.
Boolean result = smallerTOkenValue.contains(","); if (result == true) {
consider replacing it with this if (smallerTOkenValue.contains(",")){
I'm going to assume that this was a mistake smallerTOkenValue.toLowerCase().replace("(", "").replace(",", "").replace(")", "")
specifically .replace(",", "")
because a few lines above you ask if (smallerTOkenValue.contains(","))
and if it did you split it up. Which means that your smallerTOkenValue should not contain any ','
Lastly I believe you can actually use a small form of recursion to simplify your code some (providing of course you split your big method into smaller methods). below is my final outcome. (I have not tested this, as I'm typing this in notepad++). Notice that the second to last method uses calls itself.
public static boolean validationTypeOfSQL(String sourceFile, Tokenization tokenization, List<String> uniqueKeywordList) { List<Token> createSourceCodeTokens = tokenization.createSourceCodeTokens(sourceFile); for (Token x : createSourceCodeTokens) { if(isSourceCodeTokenValid(x, uniqueKeyWord)) return true; } return false; } private static boolean isSourceCodeTokenValid(Token x, List<String> uniqueKeywordList){ String smallerTokens[] = tokenization.tokenToSmallerToken(x.getToken()); for (String smallerTOkenValue : smallerTokens) { if(smallerTokenIsValid(smallerTOkenValue, uniqueKeyWord)) return true; } return false; } private static boolean smallerTokenIsValid(String smallerTOkenValue, List<String> uniqueKeywordList){ if (smallerTOkenValue.contains(",")) { for (String ts : smallerTOkenValue.split(",")) { smallerTokenIsValid(ts, uniqueKeywordList); } } else { for (String uniqueKeyWord : uniqueKeywordList) { if(uniqueKeywordIsEqualToTokenValue(uniqueKeyWord, smallerTOkenValue)){ return true; } } } return false; } private static boolean uniqueKeywordListIsEqualToTokenValue(String uniqueKeyWord, string smallerTOkenValue){ string strippedTokenValue = smallerTOkenValue.toLowerCase().replace("(", "").replace(")", "").replace("\t", ""); return uniqueKeyWord.toLowerCase().equals(strippedTokenValue)) }