You want to use Object as a generic class to use. Also, no need to check null AND an empty string (it'll always be null or a non-empty string). Here's the modifications you want:
public class Criteria {
public String FieldName;
public String Operator;
public Object FieldValue;
public Criteria(String f_name, Object f_value) {
FieldName = f_name;
FieldValue = f_value;
Operator = '=';
}
public String getSOQLCriteria() {
returnif(FieldValue fieldNameinstanceOf +String) '{
' + Operator + ' \'' return FieldName + FieldValueOperator + '\'';String.escapeSingleQuotes(String.valueOf(FieldValue));
}
return FieldName + Operator + FieldValue;
}
public String IsFieldValueGiven() {
return FieldValue != null;
}
}
The actual getSOQLCriteria method would need to check the data type of the field value to determine the appropriate method to use. The above method should work for all primitive data types.