diff --git a/dev-tools/assets/intelliJ/fileTemplates/AEPE - Selector Structure.cls b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Selector Structure.cls index 4f086ea..bdc93bb 100644 --- a/dev-tools/assets/intelliJ/fileTemplates/AEPE - Selector Structure.cls +++ b/dev-tools/assets/intelliJ/fileTemplates/AEPE - Selector Structure.cls @@ -1,75 +1,75 @@ -public virtual inherited sharing class ${NAME} +public virtual without sharing class ${NAME} extends fflib_SObjectSelector implements I${NAME} { + /** + * Runs the query in User Mode, respecting FLS, CRUD & sharing rules + * + * @return New instance of the selector + */ public static I${NAME} newInstance() { - return (I${NAME}) Application.Selector.newInstance(Schema.${SObject_API_Name}.SObjectType); + return (I${NAME}) + ((fflib_SObjectSelector) Application.Selector.newInstance(Schema.${SObject_API_Name}.SObjectType)) + .setDataAccess(fflib_SObjectSelector.DataAccess.USER_MODE); } - + + /** + * Runs the query in System Mode, disabling FLS, CRUD & sharing rules + * + * @return New instance of the selector + */ public static I${NAME} newWithoutSharingInstance() { - return (I${NAME}) Application.ElevatedSelector.newInstance(Schema.${SObject_API_Name}.SObjectType); + return (I${NAME}) + ((fflib_SObjectSelector) Application.Selector.newInstance(Schema.${SObject_API_Name}.SObjectType)) + .setDataAccess(fflib_SObjectSelector.DataAccess.SYSTEM_MODE); } - - public static I${NAME} newInheritedSharingInstance() - { - return (I${NAME}) Application.NoSharingSelector.newInstance(Schema.${SObject_API_Name}.SObjectType); - } - + + /** + * Class constructor + * This should not be used directly by an application but only by fflib + */ public ${NAME}() { super(); } - public ${NAME}(Boolean includeFieldSetFields, Boolean enforceCRUD, Boolean enforceFLS) - { - super(includeFieldSetFields, enforceCRUD, enforceFLS); - } - - public List getSObjectFieldList() + /** + * The fields to always include in all queries + * + * @return Returns a list of default fields that are always queried + */ + public virtual List getSObjectFieldList() { - return new List + List sObjectFields = new List { ${SObject_API_Name}.Id }; + // Uncomment the following line if this selector is extended from another selector + // result.addAll(super.getSObjectFieldList()); + return sObjectFields; } - public Schema.SObjectType getSObjectType() + /** + * Gets the SObjectType of the records returned by this selector class + * + * @return Returns the SObjectType of the returned records + */ + public Schema.SObjectType getSObjectType() { return Schema.${SObject_API_Name}.SObjectType; } - - public virtual List<${SObject_API_Name}> selectById(Set idSet) + + /** + * Gets ${SObject_API_Name} records by their Id + * + * @param idSet The Ids to query + * + * @return Returns a list of ${SObject_API_Name} records matching the idSet + */ + public virtual List<${SObject_API_Name}> selectById(Set idSet) { return (List<${SObject_API_Name}>) selectSObjectsById(idSet); } - - public with sharing class WithSharing extends ${NAME} - { - // Constructor that will enforce CRUD and FLS - public WithSharing() - { - super(true, true, true); - } - - public override List<${SObject_API_Name}> selectById(Set idSet) - { - return super.selectById(idSet); - } - } - - public without sharing class WithoutSharing extends ${NAME} - { - // Constructor that will enforce CRUD and FLS - public WithoutSharing() - { - super(true, false, false); - } - - public override List<${SObject_API_Name}> selectById(Set idSet) - { - return super.selectById(idSet); - } - } } \ No newline at end of file