Commit 258453cc authored by Christoph Richter's avatar Christoph Richter
Browse files

MathCommandRegister: Decreased cognitive complexity of isTargetLanguageCommand

parent 27152df8
......@@ -46,7 +46,17 @@ public abstract class MathCommand {
*
* @return targetLanguageCommandName
*/
public HashSet<String> getTargetLanguageCommandNames() {
protected HashSet<String> getTargetLanguageCommandNames() {
return targetLanguageCommandNames;
}
public boolean isTargetLanguageCommand(String command) {
if (!command.isEmpty())
for (String s : getTargetLanguageCommandNames())
if (s.contains(command))
return true;
return false;
}
}
......@@ -27,21 +27,18 @@ public abstract class MathCommandRegister {
public boolean isMathCommand(String functionName) {
boolean isMathCommand = false;
if (!functionName.isEmpty()) {
if (getMathCommand(functionName) != null) {
isMathCommand = true;
} else {
isMathCommand = isTargetLanguageCommand(functionName);
}
if (getMathCommand(functionName) != null) {
isMathCommand = true;
} else {
isMathCommand = isTargetLanguageCommand(functionName);
}
return isMathCommand;
}
private boolean isTargetLanguageCommand(String command) {
for (MathCommand mathCommand : mathCommands)
for (String s : mathCommand.getTargetLanguageCommandNames())
if (s.contains(command))
return true;
if (mathCommand.isTargetLanguageCommand(command))
return true;
return false;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment