The Selector class template
A Selector class, like the Domain class, utilizes inheritance to gain some standard functionality; in this case, the base class delivered through the FinancialForce.com Enterprise Apex Patterns library, fflib_SObjectSelector
.
A basic example is as follows:
public class RacesSelector extends fflib_SObjectSelector { public List<Schema.SObjectField> getSObjectFieldList() { return new List<Schema.SObjectField> { Race__c.Id, Race__c.Name, Race__c.Status__c, Race__c.Season__c, Race__c.FastestLapBy__c, Race__c.PollPositionLapTime__c, Race__c.TotalDNFs__c }; } public Schema.SObjectTypegetSObjectType() { return Race__c.sObjectType; } }
Tip
The base class uses Dynamic SOQL to implement the features described in this chapter. One potential disadvantage this can bring is that references to the fields are made without the Apex compiler knowing about them, and...