So I have a string that is made of three parts: fieldName, operator and value
Assuming the parameters have these values:
fieldName: firstName
operator: equals
value: Nikola
I want to be able to evaluate that, firstName equals Nikola as a condition with the help of Java reflections. Is this possible?
if(obj.getFirstName().equals(value))
Edit (Xenteros):
According to the discussion in the comments, I decided to add the explanation to the question as the MCVE should be in the question itself:
Problem description:
There is a class which has multiple fields, all of them contain Strings. There is a request for a solution to get the field value by field's name and compare to another String.
There are multiple operators available. For example: <, <=, >= etc, but there is also equals available which was unfortunately added as an example before. If the user passes "equals" to the method, equals should be invoked.
Example input:
User u, such that u.firstName.equals("John"))
"firstName",
"John",
"<=".
Expected output:
true