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 Enterprise Apex Patterns library, fflib_SObjectSelector
, is used to reduce the coding overhead in performing queries, adding some standard behaviors, and supporting best practices. These will be discussed in further detail throughout this chapter.
A basic example of a Selector class for querying Races records is as follows and leverages the ApplicationSelector
class, which in turn extends the fflib_SObjectSelector
class. As mentioned earlier, this is used to customize the default behavior of the fflib_SObjectSelector
class to enable user mode by default for all Selectors’ logic:
public inherited sharing class RacesSelector
extends ApplicationSelector {
public List<Schema.SObjectField> getSObjectFieldList() {
return new List<Schema.SObjectField> {
Race__c...