I have a string set of field names populated as below:
Set<String> setAllCustomSettingFields = new Set<String>();
Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
for(String objectName : gd.keySet()){
Schema.SObjectType result = gd.get(objectName);
if(result.getDescribe().isCustomSetting()){
Map<String, Schema.SObjectField> objectFields = result.getDescribe().fields.getMap();
for(String fieldString : objectFields.keySet()) {
setAllCustomSettingFields.add(fieldString);
}
}
}
All the strings in the set turn out to be all lowercase. It contains, for example, 'api_url__c.'
However, setAllCustomSettingFields.contains('API_URL__c')
was false, whereas setAllCustomSettingFields.contains('api_url__c')
is true.
I have never seen that before, always thought all Apex is case insensitive, and the documentation on contains() doesn't say anything about it.
Best Answer
Yes. Collection membership is case sensitive.
This applies to Sets:
and to Maps: