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 ...

Get Force.com Enterprise Architecture - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.