There’s no way (normally, at least) to do this by replacing the method name dynamically, as you state. This is due to a fundamental principle in object-oriented programming called “separation of data and function”. What you’re suggesting would essentially treat function as data, which isn’t generally a good idea.
The only way to really do what you’re trying to do would be a conditional statement, either an if/else bock or a switch statement:
public void method(String something) {
if(something.equals("a")) {
KeywordUtil.logInfo(...)
} else if (something.equals("b")) {
KeywordUtil.markError(...)
} // and so on...
}
or
public void method(String something) {
switch (something) {
case "a":
KeywordUtil.logInfo(...)
case "b":
KeywordUtil.markError(...)
// and so on...
}
}
There actually is a way to break this “rule” using reflection, however, I don’t generally recommend going this route unless you are extremely familiar with how reflection works.