Is there a way we can input an code expression as Input data?

Hi all,
I have a question: Is there a way to input code expression as Input’s data?
For example, I have a method:
@Keyword
def clickElementByXPath(String xpath) {
try {
WebDriver driver = DriverFactory.getWebDriver();
driver.findElement(By.xpath(xpath)).click();
KeywordUtil.markPassed(“Element has been clicked”)
} catch (WebElementNotFoundException e) {
KeywordUtil.markFailed(“Element not found”)
} catch (Exception e) {
KeywordUtil.markFailed(“Fail to click on element”)
}
}

Normally, I will input an xpath: //div//span//a[text()=‘Refugees: Displaced, not discouraged’] in Value field.

I want to make it so that I can input: //div//span//a[text()=‘“+variable+”’] and variable = “Refugees: Displaced, not discouraged” instead.

It is not practical to create methods for each xpath and it is easier to simply change variable instead of changing a whole xpath.

Any help is appreciated. Thank you all beforehand and have a nice day

Modify your keyword to take two variables, e.g:

def clickElementByXPath(String xpath, String value)

Thanks for your advice, @Ibus but that is not what I am aiming to do here.
What I want is to be able to input code expression so that I can do it with all xpath, not limiting them to a particular function. The variable can be added to the Test Case.
For example from a fixed xpath:
//div//span//a[text()=‘Refugees: Displaced, not discouraged’]
i want to change them at will: //div//span//a[text()=’"+variable+"’]
Or //div//span[text()=’"+variable+"’]//a ect
The advantage is that you can create test case and let others use it by simply entering the keyword data, not the full xpath. Not to mention it also enable more modifications like making them all lower-case for easier compare…