I don't know if Apex supports generics but how can I make the below class more generics where I should be able to pass any data type?
below is the example:
the problem I have is this:
public class Criteria {
public String FieldName;
public String Operator;
public String FieldValue;
public Criteria(String f_name, String f_value) {
FieldName = f_name;
FieldValue = f_value;
Operator = '=';
}
public String getSOQLCriteria() {
return fieldName + ' ' + Operator + ' \'' + FieldValue + '\'';
}
public String IsFieldValueGiven() {
return FieldValue != null && FieldValue != '';
}
}
calling the code:
Criteria c1 = new Criteria('empNum__c', 'john'); //good
the issue is, if I have number or date then below code will not work, its expecting string, what do I need to do to make it work the above class code more in a generic way?
Criteria c2 = new Criteria('empNum__c', 145); //number - error