You can reference the field itself via its API name using this compile-time checked syntax:
// As a specific type that you can then do e.g. metadata describes calls from
SObjectField f = YourCustomObject__c.MeetingType__c;
// Just the string 'MeetingType__c' but compile-time checked
String s = String.valueOf(YourCustomObject__c.MeetingType__c);
but I think you are talking about the picklist option values themselves. Where Apex logic is dependent on those, this rather brute-force approach works:
public class MeetingType {
// Rest of code is dependent on these variable names not the values
// so the values can be changed in the future or dynamically loaded
public static final String TYPE_1 = 'Type 1';
public static final String TYPE_2 = 'Type 2';
...
}
with the values referenced in other code via e.g. MeetingType.TYPE_1
.
Unfortunately, Apex enums are very basic in that they can't represent names containing spaces or that are not legal Apex variable names. You could use enum values if you don't mind adding supporting methods and maps (or switch
statements) to do the conversions:
public class MeetingType {
public enum Value {
TYPE_1,
TYPE_2,
...
}
public static String toString(Value v) {
...
}
public static Value valueOf(String s) {
...
}
}
But as you comment, there isn't an elegant solution AFAIK.